Code Monkey home page Code Monkey logo

tindercloneswiftui's Introduction

About me

HiπŸ‘‹, my name is Alejandro Piguave. I am a mobile developerπŸ‘¨β€πŸ’» from Madrid, Spain πŸ‡ͺπŸ‡Έ. My most used languages are Java, Kotlin and Swift.

A timeline of my work πŸ’Ό

I got into programming in 2015 because I was interested in making videogames. Later, I got interested in Android development so I learned Java. Over the next 5 years, I would develop Android applications in my free time.

Some of my personal projects

After that, I worked as an Android engineer at Ciber Experis from February 2020 to April 2021 and at Accenture from April 2021 until September 2021.

Meanwhile, I've been working on some open-source side projects where I focus on improving the quality of my code and learning new technologies. Here are some examples:

I currently study Software Engineering at Polytechnic University of Madrid.

tindercloneswiftui's People

Contributors

alejandro-piguave avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

tindercloneswiftui's Issues

Instructions for project

I am wondering if you can provide step by step instructions for this project or if you followed a tutorial, can you provide the link?
I cannot seem to get this project working right once i get to the setting up profile.

Please help: Value of type 'Date' has no member 'years'

I am using Xcode 14.1, iOS 16 and recreating your project.

In your file, FirestoreUser.swift, there is an issue with the return of age:

var age: Int{
return Date().years(from: birthDate)
}

I am getting this error :: Value of type 'Date' has no member 'years'

Please advise..
Thank you,

Setting Up

Hi, amazing project. I do not know if you are still online but a little update is needed. There are issues with the packages. Can you take a look that would be increible :D gracias

Issues in final update

After add Google plist for Firebase, the following errors are coming up all in one file: EditProfileViewModel.swift:

  1. Invalid redeclaration of 'ProfilePicture' on line 11
  2. 'ProfilePicture' is ambiguous for type lookup in this context on line 22
  3. Type of expression is ambiguous without more context on line 30
  4. 'ProfilePicture' is ambiguous for type lookup in this context on line 40
  5. 'ProfilePicture' is ambiguous for type lookup in this context on line 77
  6. Type of expression is ambiguous without more context on line 79
  7. Command SwiftCompile failed with a nonzero exit code

Please assist

Attached is the code:

//
// EditProfileViewModel.swift
// tinder-clone
//
// Created by Alejandro Piguave on 27/10/22.
//

import Foundation
import UIKit

struct ProfilePicture: Hashable{
let filename: String?
let picture: UIImage
}

class EditProfileViewModel: NSObject, ObservableObject {

private let firestoreRepository: FirestoreRepository = FirestoreRepository.shared
private let storageRepository: StorageRepository = StorageRepository.shared

@Published var userProfile: FirestoreUser? = nil
@Published var userPictures: [ProfilePicture] = []
@Published var isProfileUpdated: Bool = false

@Published private (set) var isLoading: Bool = true
@Published private (set) var error: String = ""

func fetchProfile() {
    self.isLoading = true
    Task{
        do{
            //Fetch profile information
            let user = try await firestoreRepository.getUserProfile()
            DispatchQueue.main.async {
                self.userProfile = user
            }

            //Fetch pictures
            let pictures = try await storageRepository.getPicturesFromUser(fileNames: user.pictures)
            var profilePictures: [ProfilePicture] = []
            for i in user.pictures.indices {
                profilePictures.append(ProfilePicture(filename: user.pictures[i], picture: pictures[i]))
            }

            let finalProfilePictures = profilePictures
            DispatchQueue.main.async {
                self.userPictures = finalProfilePictures
                self.isLoading = false
            }
        }catch{
            publishError(message: error.localizedDescription)
        }
    }
}

//Update only profile fields
func updateProfile(modified profileFields: [String: Any]) {
    self.isLoading = true
    Task{
        do{
            try await firestoreRepository.updateUserProfile(modified: profileFields)
            
            self.isLoading = false
            self.isProfileUpdated = true
        }catch{
            publishError(message: error.localizedDescription)
        }
    }
}

/**
 Updates the profile pictures

 - Parameter oldPictures: Array of the file names of the pictures that are already uploaded, in their respective order.
 - Parameter newPictures: Array of either: the file name of a picture that is already uploaded or a new picture.
 */
func updateProfile(newPictures: [ProfilePicture], modified profileFields: [String: Any]? = nil){
    self.isLoading = true
    Task{
        let oldPictures = userProfile!.pictures
        //Gets the name of the pictures that are not among the new pictures.
        let filesToDelete = oldPictures.filter({ fileName in
            !newPictures.contains(where: { newPicture in
                if let newPictureFilename = newPicture.filename {
                    return fileName == newPictureFilename
                } else {
                    return false
                    
                }
            })
        })
        
        let picturesToUpload: [UIImage] = newPictures.compactMap({ pictureUpload in
            if pictureUpload.filename == nil{
                return pictureUpload.picture
            } else {
                return nil
            }
        })
        
        do{
            async let deletePictures: () = storageRepository.deleteUserPictures(fileNames: filesToDelete)
            async let uploadPictures = storageRepository.uploadUserPictures(picturesToUpload)
            
            let (_, newFileNames): ((), [String]) = try await (deletePictures, uploadPictures)
            
            var updatedFileNames: [String] = []
            var count: Int = 0
            
            newPictures.forEach({
                if let oldFilename = $0.filename {
                    updatedFileNames.append(oldFilename)
                } else {
                    updatedFileNames.append(newFileNames[count])
                    count += 1
                }
            })
            
            //If more values need to be updated then create a copy, otherwise create an empty dictionary
            var allProfileFields: [String: Any] = profileFields ?? [:]
            allProfileFields["pictures"] = updatedFileNames
            
            try await firestoreRepository.updateUserProfile(modified: allProfileFields)
            self.isLoading = false
            self.isProfileUpdated = true
        }catch{
            publishError(message: error.localizedDescription)
        }
    }
}


private func publishError(message: String) {
    DispatchQueue.main.async {
        self.error = message
        self.isLoading = false
    }
}

}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.