rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents/weight {
match /{document=**} {
allow write: if true;
allow read, write, delete: if
request.auth != null && request.auth.uid == d;
}
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extension UserDefaults { | |
| static func loadJSON<T>(forKey: String) -> T? { | |
| let defaults = UserDefaults.standard | |
| if let data = defaults.object(forKey: forKey) as? Data { | |
| let decoder = JSONDecoder() | |
| if let loadedData = try? decoder.decode(T.self, from: data) { | |
| return loadedData | |
| } | |
| } | |
| return nil |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // This is how to change the background of a List. | |
| // It is no longer necessary to reference UITableView.appearance() | |
| List { | |
| // list content | |
| } | |
| .scrollContentBackground(.hidden) // <-------- Here is the magic |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Configuration | |
| let identifier = "iCloud.{your-container-name}" | |
| let token = "{your-token-generated-from-cloudkit-console}" | |
| let container = CKWSContainer(identifier: identifier, token: token, enviornment: .development) | |
| // Create an operation that queries all records of the "ExampleType" | |
| let queryOperation = CKWSQueryOperation(query: CKWSQuery(recordType: "ExampleType")) | |
| queryOperation.recordMatchedBlock = { recordID, result in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| import KeychainAccess | |
| @propertyWrapper | |
| struct KeychainStorage<T: Codable>: DynamicProperty { | |
| typealias Value = T | |
| let key: String | |
| @State private var value: Value? | |
| init(wrappedValue: Value? = nil, _ key: String) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func signInWithBiometrics() { | |
| let context = LAContext() | |
| var error: NSError? | |
| if context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) { | |
| let reason = "Please authenticate yourself to unlock your places." | |
| context.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: reason) { success, authenticationError in | |
| if success { | |
| Task { @MainActor in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // MultiComponentePicker.swift | |
| // SwiftJourney | |
| // | |
| // Created by Rodney Aiglstorfer on 10/2/22. | |
| // | |
| import SwiftUI | |
| struct MultiComponentePicker: View { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Text("Your Text").font(.system(.body, design: .rounded)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct ContentView : View { | |
| @State var text1 = "" | |
| @State var text2 = "" | |
| @StateObject var model = ViewModel() | |
| var body: some View { | |
| TextField("Text 1", text: $text1) | |
| { editing in | |
| print("Editing?: \(editing)") | |
| } onCommit: { |
If the builds are part of a single target, the best option is to give both configuration
files unique names (e.g. GoogleService-Info-Free.plist and GoogleService-Info-Paid.plist).
Then choose at runtime which plist to load. This is shown in the following example:
// Load a named file.
let filePath = Bundle.main.path(forResource: "MyGoogleService", ofType: "plist")
guard let fileopts = FirebaseOptions(contentsOfFile: filePath!)
else { assert(false, "Couldn't load config file") }
FirebaseApp.configure(options: fileopts)