Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

50 medium widget #334

Open
wants to merge 21 commits into
base: dev
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Reconnect firestore to widget
aking618 committed Oct 14, 2024
commit e601402847b5c543480dd3903707c1c06aef887a
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@
)
}

func timeline(for configuration: ConfigurationAppIntent, in context: Context) async -> Timeline<MaintenanceEntry> {

Check warning on line 31 in Basic-Car-Maintenance-Widget/BasicCarMaintenanceWidget.swift

GitHub Actions / SwiftLint

Line should be 110 characters or less; currently it has 119 characters (line_length)
let currentDate = Date()
let nextUpdate = Calendar.current.date(byAdding: .hour, value: 1, to: currentDate)!

@@ -38,7 +38,7 @@
MaintenanceEntry(date: currentDate, configuration: configuration, maintenanceEvents: events)
case .failure(let error):
// Returns an empty list of options
MaintenanceEntry(date: currentDate, configuration: configuration, maintenanceEvents: [], error: error.localizedDescription)

Check warning on line 41 in Basic-Car-Maintenance-Widget/BasicCarMaintenanceWidget.swift

GitHub Actions / SwiftLint

Line should be 110 characters or less; currently it has 135 characters (line_length)
}

return Timeline(entries: [entry], policy: .after(nextUpdate))
@@ -51,7 +51,7 @@
let maintenanceEvents: [MaintenanceEvent]
let error: String?

init(date: Date, configuration: ConfigurationAppIntent, maintenanceEvents: [MaintenanceEvent], error: String? = nil) {

Check warning on line 54 in Basic-Car-Maintenance-Widget/BasicCarMaintenanceWidget.swift

GitHub Actions / SwiftLint

Line should be 110 characters or less; currently it has 122 characters (line_length)
self.date = date
self.configuration = configuration
self.maintenanceEvents = maintenanceEvents
@@ -67,7 +67,7 @@
FirebaseApp.configure()

try? Auth.auth().useUserAccessGroup(Bundle.main.keychainAccessGroup)
let useEmulator = UserDefaults.standard.bool(forKey: "useEmulator")
let useEmulator = true // Process arguments aren't respected here from the main app
if useEmulator {
let settings = Firestore.firestore().settings
settings.host = "localhost:8080"
2 changes: 1 addition & 1 deletion Basic-Car-Maintenance-Widget/Service/DataService.swift
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@
do {
let docRef = Firestore
.firestore()
.collection("\(FirestoreCollection.vehicles)/\(vehichleID)/\(FirestoreCollection.maintenanceEvents)")

Check warning on line 38 in Basic-Car-Maintenance-Widget/Service/DataService.swift

GitHub Actions / SwiftLint

Line should be 110 characters or less; currently it has 129 characters (line_length)
let snapshot = try await docRef.getDocuments()
let events = snapshot.documents.compactMap {
try? $0.data(as: MaintenanceEvent.self)
@@ -70,7 +70,7 @@

let docRef = Firestore
.firestore()
.collectionGroup(FirestoreCollection.vehicles)
.collection(FirestoreCollection.vehicles)
.whereField(FirestoreField.userID, isEqualTo: userID)

do {
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
// See LICENSE for license information.
//

import FirebaseAuth
import SwiftUI
import WidgetKit

@@ -15,11 +16,15 @@ struct BasicCarMaintenanceWidgetEntryView: View {
var entry: Provider.Entry

var body: some View {
switch widgetFamily {
case .systemMedium:
MediumMaintenanceView(entry: entry)
default:
Text("Unimplemented widget family: \(widgetFamily.rawValue)")
if Auth.auth().currentUser != nil {
switch widgetFamily {
case .systemMedium:
MediumMaintenanceView(entry: entry)
default:
Text("Unimplemented widget family: \(widgetFamily.rawValue)")
}
} else {
Text("Please sign in to use this widget.")
}
}
}

Unchanged files with check annotations Beta

#Preview("Error View", as: .systemMedium) {
BasicCarMaintenanceWidget()
} timeline: {
MaintenanceEntry(date: .now, configuration: .demo, maintenanceEvents: .demo, error: "Unexpected error occurred.")

Check warning on line 57 in Basic-Car-Maintenance-Widget/Views/MediumMaintenanceView.swift

GitHub Actions / SwiftLint

Line should be 110 characters or less; currently it has 117 characters (line_length)
}