Widget Extension Fixes: - Create standalone WidgetDataProvider for widget data isolation - Add WIDGET_EXTENSION compiler flag for conditional compilation - Fix DataController references in widget-shared files - Sync widget version numbers with main app (23, 1.0.2) - Add WidgetBackground color to asset catalog Warning Resolutions: - Fix UIScreen.main deprecation in BGView and SharingListView - Fix Text '+' concatenation deprecation in PurchaseButtonView and SettingsTabView - Fix exhaustive switch in BiometricAuthManager (add .none case) - Fix var to let in ExportService (3 instances) - Fix unused result warning in NoteEditorView - Fix ForEach duplicate ID warnings in MonthView and YearView Code Quality Improvements: - Wrap bypassSubscription in #if DEBUG for security - Rename StupidAssCustomWidgetObservableObject to CustomWidgetStateViewModel - Add @MainActor to IconViewModel - Replace fatalError with graceful fallback in SharedModelContainer - Add [weak self] to closures in DayViewViewModel - Add OSLog-based AppLogger for production logging - Add ImageCache with NSCache for memory efficiency - Add AccessibilityHelpers with Reduce Motion support - Create DataControllerProtocol for dependency injection - Update .gitignore with secrets exclusions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
68 lines
2.9 KiB
Swift
68 lines
2.9 KiB
Swift
//
|
|
// CustomWigetView.swift
|
|
// Feels (iOS)
|
|
//
|
|
// Created by Trey Tartt on 4/2/22.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct CustomWigetView: View {
|
|
@AppStorage(UserDefaultsStore.Keys.theme.rawValue, store: GroupUserDefaults.groupDefaults) private var theme: Theme = .system
|
|
@AppStorage(UserDefaultsStore.Keys.textColor.rawValue, store: GroupUserDefaults.groupDefaults) private var textColor: Color = DefaultTextColor.textColor
|
|
@StateObject private var selectedWidget = CustomWidgetStateViewModel()
|
|
|
|
var body: some View {
|
|
ZStack {
|
|
theme.currentTheme.secondaryBGColor
|
|
VStack {
|
|
ScrollView(.horizontal) {
|
|
HStack {
|
|
ForEach(UserDefaultsStore.getCustomWidgets(), id: \.uuid) { widget in
|
|
CustomWidgetView(customWidgetModel: widget)
|
|
.frame(width: 50, height: 50)
|
|
.cornerRadius(10)
|
|
.onTapGesture {
|
|
EventLogger.log(event: "show_widget")
|
|
selectedWidget.selectedItem = widget.copy() as? CustomWidgetModel
|
|
selectedWidget.showSheet = true
|
|
}
|
|
}
|
|
RoundedRectangle(cornerRadius: 10).fill().foregroundColor(theme.currentTheme.secondaryBGColor)
|
|
.frame(width: 50, height: 50)
|
|
.overlay(
|
|
Image(systemName: "plus")
|
|
)
|
|
.onTapGesture {
|
|
EventLogger.log(event: "tap_create_new_widget")
|
|
selectedWidget.selectedItem = CustomWidgetModel.randomWidget
|
|
selectedWidget.showSheet = true
|
|
}
|
|
}
|
|
.padding()
|
|
}
|
|
.background(RoundedRectangle(cornerRadius: 10).fill().foregroundColor(theme.currentTheme.bgColor))
|
|
.padding()
|
|
.cornerRadius(10)
|
|
|
|
Text("[\(String(localized: "how_to_add_widget"))](https://support.apple.com/guide/iphone/add-widgets-iphb8f1bf206/ios)")
|
|
.accentColor(textColor)
|
|
.padding(.bottom)
|
|
}
|
|
}
|
|
.fixedSize(horizontal: false, vertical: true)
|
|
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
|
|
.sheet(isPresented: $selectedWidget.showSheet) {
|
|
if let selectedItem = selectedWidget.selectedItem {
|
|
CreateWidgetView(customWidget: selectedItem)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
struct CustomWigetView_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
CustomWigetView()
|
|
}
|
|
}
|