Skip to content

Instantly share code, notes, and snippets.

View hrvolapeter's full-sized avatar
🔨
Bitwelding

Peter Hrvola hrvolapeter

🔨
Bitwelding
View GitHub Profile
@hrvolapeter
hrvolapeter / NoteListViewModel.swift
Last active September 6, 2020 06:39
Dummy version of list view model
import Foundation
class NoteListViewModel: ObservableObject {
@Published var notes = [
Note.init(id: "0", title: "Note 0", createdTime: .init(), content: "Content of note 0", userId: "0", deleted: nil, parentId: nil, tags: ["tag 1"]),
Note.init(id: "1", title: "Note 1", createdTime: .init(), content: "Content of note 1", userId: "0", deleted: nil, parentId: nil, tags: ["Tag 1"])
]
}
@hrvolapeter
hrvolapeter / Note.swift
Created September 6, 2020 06:08
Zetten note model
import FirebaseFirestore
import FirebaseFirestoreSwift
import Foundation
import GRDB
struct Note: Codable, Identifiable {
var id: String = UUID().uuidString
var title: String
var createdTime = Timestamp()
var content: String
handler: {res,err in
print(res)
print(err)
}
action: {
self.authenticationService.signIn(email: self.email, password: self.password, handler: {_,_ in })
}
@hrvolapeter
hrvolapeter / Injected.swift
Created March 29, 2020 21:31
Injected zetten
@Injected var authenticationService: AuthenticationService
@hrvolapeter
hrvolapeter / Action.swift
Created March 29, 2020 21:31
Zetten signin action
action: {
self.authenticationService.signUp(email: self.email, password: self.password, handler: {_,_ in })
}
@hrvolapeter
hrvolapeter / CreateAccountView.swift
Created March 29, 2020 21:30
CreateAccountView zetten changes
struct CreateAccountView: View {
@State var email: String = ""
@State var password: String = ""
@Injected var authenticationService: AuthenticationService
...
@hrvolapeter
hrvolapeter / Podfile
Created March 29, 2020 20:45
podfile zetten
pod 'Firebase/Analytics'
pod 'FirebaseCore'
pod 'Firebase/Auth'
pod 'Firebase/Firestore'
pod 'Firebase/Crashlytics'
pod "FirebaseFirestoreSwift"
pod 'GRDB.swift'
pod 'Resolver'
post_install do |installer|
installer.pods_project.targets.select { |target| target.name == "GRDB.swift" }.each do |target|
import SwiftUI
import Resolver
struct ContentView: View {
@ObservedObject var authenticationService: AuthenticationService = Resolver.resolve()
var body: some View {
Group {
if (authenticationService.user == nil) {
LoginView()
import Foundation
import Resolver
extension Resolver: ResolverRegistering {
public static func registerAllServices() {
register { AuthenticationService() }.scope(application)
}
}