diff --git a/IceCubesApp.xcodeproj/project.pbxproj b/IceCubesApp.xcodeproj/project.pbxproj index da7bce4f..7614fd60 100644 --- a/IceCubesApp.xcodeproj/project.pbxproj +++ b/IceCubesApp.xcodeproj/project.pbxproj @@ -1187,7 +1187,7 @@ INFOPLIST_FILE = IceCubesNotifications/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = IceCubesNotifications; INFOPLIST_KEY_NSHumanReadableCopyright = ""; - IPHONEOS_DEPLOYMENT_TARGET = 17.0; + IPHONEOS_DEPLOYMENT_TARGET = 18.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1222,7 +1222,7 @@ INFOPLIST_FILE = IceCubesNotifications/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = IceCubesNotifications; INFOPLIST_KEY_NSHumanReadableCopyright = ""; - IPHONEOS_DEPLOYMENT_TARGET = 17.0; + IPHONEOS_DEPLOYMENT_TARGET = 18.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1261,7 +1261,7 @@ INFOPLIST_FILE = IceCubesAppWidgetsExtension/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = IceCubesAppWidgetsExtension; INFOPLIST_KEY_NSHumanReadableCopyright = ""; - IPHONEOS_DEPLOYMENT_TARGET = 17.4; + IPHONEOS_DEPLOYMENT_TARGET = 18.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1297,7 +1297,7 @@ INFOPLIST_FILE = IceCubesAppWidgetsExtension/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = IceCubesAppWidgetsExtension; INFOPLIST_KEY_NSHumanReadableCopyright = ""; - IPHONEOS_DEPLOYMENT_TARGET = 17.4; + IPHONEOS_DEPLOYMENT_TARGET = 18.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1330,7 +1330,7 @@ INFOPLIST_FILE = IceCubesShareExtension/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = "Ice Cubes"; INFOPLIST_KEY_NSHumanReadableCopyright = ""; - IPHONEOS_DEPLOYMENT_TARGET = 17.0; + IPHONEOS_DEPLOYMENT_TARGET = 18.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1364,7 +1364,7 @@ INFOPLIST_FILE = IceCubesShareExtension/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = "Ice Cubes"; INFOPLIST_KEY_NSHumanReadableCopyright = ""; - IPHONEOS_DEPLOYMENT_TARGET = 17.0; + IPHONEOS_DEPLOYMENT_TARGET = 18.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1548,7 +1548,7 @@ "INFOPLIST_KEY_UIStatusBarStyle[sdk=iphonesimulator*]" = UIStatusBarStyleDefault; INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown"; - IPHONEOS_DEPLOYMENT_TARGET = 17.0; + IPHONEOS_DEPLOYMENT_TARGET = 18.0; LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks"; "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 13.0; @@ -1573,7 +1573,7 @@ SWIFT_UPCOMING_FEATURE_REGION_BASED_ISOLATION = YES; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2,7"; - _EXPERIMENTAL_SWIFT_EXPLICIT_MODULES = YES; + _EXPERIMENTAL_SWIFT_EXPLICIT_MODULES = NO; }; name = Debug; }; @@ -1615,7 +1615,7 @@ "INFOPLIST_KEY_UIStatusBarStyle[sdk=iphonesimulator*]" = UIStatusBarStyleDefault; INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown"; - IPHONEOS_DEPLOYMENT_TARGET = 17.0; + IPHONEOS_DEPLOYMENT_TARGET = 18.0; LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks"; "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 13.0; @@ -1640,7 +1640,7 @@ SWIFT_UPCOMING_FEATURE_REGION_BASED_ISOLATION = YES; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2,7"; - _EXPERIMENTAL_SWIFT_EXPLICIT_MODULES = YES; + _EXPERIMENTAL_SWIFT_EXPLICIT_MODULES = NO; }; name = Release; }; @@ -1659,7 +1659,7 @@ INFOPLIST_FILE = IceCubesActionExtension/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = "Open in Ice Cube"; INFOPLIST_KEY_NSHumanReadableCopyright = ""; - IPHONEOS_DEPLOYMENT_TARGET = 17.0; + IPHONEOS_DEPLOYMENT_TARGET = 18.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1694,7 +1694,7 @@ INFOPLIST_FILE = IceCubesActionExtension/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = "Open in Ice Cube"; INFOPLIST_KEY_NSHumanReadableCopyright = ""; - IPHONEOS_DEPLOYMENT_TARGET = 17.0; + IPHONEOS_DEPLOYMENT_TARGET = 18.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", diff --git a/IceCubesApp/App/Main/AppView.swift b/IceCubesApp/App/Main/AppView.swift index ff72955c..f7ed8f42 100644 --- a/IceCubesApp/App/Main/AppView.swift +++ b/IceCubesApp/App/Main/AppView.swift @@ -21,10 +21,10 @@ struct AppView: View { @Environment(\.openWindow) var openWindow @Environment(\.horizontalSizeClass) private var horizontalSizeClass - @Binding var selectedTab: Tab + @Binding var selectedTab: AppTab @Binding var appRouterPath: RouterPath - @State var popToRootTab: Tab = .other + @State var popToRootTab: AppTab = .other @State var iosTabs = iOSTabs.shared @State var sidebarTabs = SidebarTabs.shared @@ -40,14 +40,14 @@ struct AppView: View { #endif } - var availableTabs: [Tab] { + var availableTabs: [AppTab] { guard appAccountsManager.currentClient.isAuth else { - return Tab.loggedOutTab() + return AppTab.loggedOutTab() } if UIDevice.current.userInterfaceIdiom == .phone || horizontalSizeClass == .compact { return iosTabs.tabs } else if UIDevice.current.userInterfaceIdiom == .vision { - return Tab.visionOSTab() + return AppTab.visionOSTab() } return sidebarTabs.tabs.map { $0.tab } } @@ -96,7 +96,7 @@ struct AppView: View { .withSheetDestinations(sheetDestinations: $appRouterPath.presentedSheet) } - private func badgeFor(tab: Tab) -> Int { + private func badgeFor(tab: AppTab) -> Int { if tab == .notifications, selectedTab != tab, let token = appAccountsManager.currentAccount.oauthToken { @@ -114,14 +114,15 @@ struct AppView: View { HStack(spacing: 0) { TabView(selection: $selectedTab) { ForEach(availableTabs) { tab in - tab - .makeContentView(selectedTab: $selectedTab, popToRootTab: $popToRootTab) - .tabItem { - tab.label - } - .tag(tab) + Tab(value: tab) { + tab.makeContentView(selectedTab: $selectedTab, popToRootTab: $popToRootTab) + } label: { + tab.label + } + .defaultVisibility(.hidden, for: .automatic) } } + .tabViewStyle(.tabBarOnly) .introspect(.tabView, on: .iOS(.v17, .v18)) { (tabview: UITabBarController) in tabview.tabBar.isHidden = horizontalSizeClass == .regular tabview.customizableViewControllers = [] diff --git a/IceCubesApp/App/Main/IceCubesApp.swift b/IceCubesApp/App/Main/IceCubesApp.swift index cc64b64d..70e1aa75 100644 --- a/IceCubesApp/App/Main/IceCubesApp.swift +++ b/IceCubesApp/App/Main/IceCubesApp.swift @@ -28,7 +28,7 @@ struct IceCubesApp: App { @State var quickLook = QuickLook.shared @State var theme = Theme.shared - @State var selectedTab: Tab = .timeline + @State var selectedTab: AppTab = .timeline @State var appRouterPath = RouterPath() @State var isSupporter: Bool = false diff --git a/IceCubesApp/App/SideBarView.swift b/IceCubesApp/App/SideBarView.swift index d5f5b69b..e6e96097 100644 --- a/IceCubesApp/App/SideBarView.swift +++ b/IceCubesApp/App/SideBarView.swift @@ -18,14 +18,14 @@ struct SideBarView: View { @Environment(UserPreferences.self) private var userPreferences @Environment(RouterPath.self) private var routerPath - @Binding var selectedTab: Tab - @Binding var popToRootTab: Tab - var tabs: [Tab] + @Binding var selectedTab: AppTab + @Binding var popToRootTab: AppTab + var tabs: [AppTab] @ViewBuilder var content: () -> Content @State private var sidebarTabs = SidebarTabs.shared - private func badgeFor(tab: Tab) -> Int { + private func badgeFor(tab: AppTab) -> Int { if tab == .notifications, selectedTab != tab, let token = appAccounts.currentAccount.oauthToken { @@ -34,7 +34,7 @@ struct SideBarView: View { return 0 } - private func makeIconForTab(tab: Tab) -> some View { + private func makeIconForTab(tab: AppTab) -> some View { HStack { ZStack(alignment: .topTrailing) { SideBarIcon(systemIconName: tab.iconName, @@ -83,7 +83,7 @@ struct SideBarView: View { .offset(x: 2, y: -2) } .buttonStyle(.borderedProminent) - .help(Tab.post.title) + .help(AppTab.post.title) } private func makeAccountButton(account: AppAccount, showBadge: Bool) -> some View { @@ -133,7 +133,7 @@ struct SideBarView: View { if let accountName { "tab.profile-account-\(accountName)" } else { - Tab.profile.title + AppTab.profile.title } } diff --git a/IceCubesApp/App/Tabs/ExploreTab.swift b/IceCubesApp/App/Tabs/ExploreTab.swift index 5b2cce1c..20e49918 100644 --- a/IceCubesApp/App/Tabs/ExploreTab.swift +++ b/IceCubesApp/App/Tabs/ExploreTab.swift @@ -14,7 +14,7 @@ struct ExploreTab: View { @Environment(Client.self) private var client @State private var routerPath = RouterPath() @State private var scrollToTopSignal: Int = 0 - @Binding var popToRootTab: Tab + @Binding var popToRootTab: AppTab var body: some View { NavigationStack(path: $routerPath.path) { diff --git a/IceCubesApp/App/Tabs/MessagesTab.swift b/IceCubesApp/App/Tabs/MessagesTab.swift index d265b73d..8fba5f2e 100644 --- a/IceCubesApp/App/Tabs/MessagesTab.swift +++ b/IceCubesApp/App/Tabs/MessagesTab.swift @@ -16,7 +16,7 @@ struct MessagesTab: View { @Environment(AppAccountsManager.self) private var appAccount @State private var routerPath = RouterPath() @State private var scrollToTopSignal: Int = 0 - @Binding var popToRootTab: Tab + @Binding var popToRootTab: AppTab var body: some View { NavigationStack(path: $routerPath.path) { diff --git a/IceCubesApp/App/Tabs/NotificationTab.swift b/IceCubesApp/App/Tabs/NotificationTab.swift index 60713ee1..7ed40796 100644 --- a/IceCubesApp/App/Tabs/NotificationTab.swift +++ b/IceCubesApp/App/Tabs/NotificationTab.swift @@ -22,8 +22,8 @@ struct NotificationsTab: View { @State private var routerPath = RouterPath() @State private var scrollToTopSignal: Int = 0 - @Binding var selectedTab: Tab - @Binding var popToRootTab: Tab + @Binding var selectedTab: AppTab + @Binding var popToRootTab: AppTab let lockedType: Models.Notification.NotificationType? diff --git a/IceCubesApp/App/Tabs/ProfileTab.swift b/IceCubesApp/App/Tabs/ProfileTab.swift index 22a80747..ed8324af 100644 --- a/IceCubesApp/App/Tabs/ProfileTab.swift +++ b/IceCubesApp/App/Tabs/ProfileTab.swift @@ -15,7 +15,7 @@ struct ProfileTab: View { @Environment(CurrentAccount.self) private var currentAccount @State private var routerPath = RouterPath() @State private var scrollToTopSignal: Int = 0 - @Binding var popToRootTab: Tab + @Binding var popToRootTab: AppTab var body: some View { NavigationStack(path: $routerPath.path) { diff --git a/IceCubesApp/App/Tabs/Settings/SettingsTab.swift b/IceCubesApp/App/Tabs/Settings/SettingsTab.swift index 7f9a822a..d86f56a4 100644 --- a/IceCubesApp/App/Tabs/Settings/SettingsTab.swift +++ b/IceCubesApp/App/Tabs/Settings/SettingsTab.swift @@ -28,7 +28,7 @@ struct SettingsTabs: View { @State private var cachedRemoved = false @State private var timelineCache = TimelineCache() - @Binding var popToRootTab: Tab + @Binding var popToRootTab: AppTab let isModal: Bool diff --git a/IceCubesApp/App/Tabs/Settings/TabbarEntriesSettingsView.swift b/IceCubesApp/App/Tabs/Settings/TabbarEntriesSettingsView.swift index 1b6c549d..603cfeb5 100644 --- a/IceCubesApp/App/Tabs/Settings/TabbarEntriesSettingsView.swift +++ b/IceCubesApp/App/Tabs/Settings/TabbarEntriesSettingsView.swift @@ -14,27 +14,27 @@ struct TabbarEntriesSettingsView: View { Form { Section { Picker("settings.tabs.first-tab", selection: $tabs.firstTab) { - ForEach(Tab.allCases) { tab in + ForEach(AppTab.allCases) { tab in tab.label.tag(tab) } } Picker("settings.tabs.second-tab", selection: $tabs.secondTab) { - ForEach(Tab.allCases) { tab in + ForEach(AppTab.allCases) { tab in tab.label.tag(tab) } } Picker("settings.tabs.third-tab", selection: $tabs.thirdTab) { - ForEach(Tab.allCases) { tab in + ForEach(AppTab.allCases) { tab in tab.label.tag(tab) } } Picker("settings.tabs.fourth-tab", selection: $tabs.fourthTab) { - ForEach(Tab.allCases) { tab in + ForEach(AppTab.allCases) { tab in tab.label.tag(tab) } } Picker("settings.tabs.fifth-tab", selection: $tabs.fifthTab) { - ForEach(Tab.allCases) { tab in + ForEach(AppTab.allCases) { tab in tab.label.tag(tab) } } diff --git a/IceCubesApp/App/Tabs/Tabs.swift b/IceCubesApp/App/Tabs/Tabs.swift index 7e6ff76c..c5c56fad 100644 --- a/IceCubesApp/App/Tabs/Tabs.swift +++ b/IceCubesApp/App/Tabs/Tabs.swift @@ -7,7 +7,7 @@ import StatusKit import SwiftUI @MainActor -enum Tab: Int, Identifiable, Hashable, CaseIterable, Codable { +enum AppTab: Int, Identifiable, Hashable, CaseIterable, Codable { case timeline, notifications, mentions, explore, messages, settings, other case trending, federated, local case profile @@ -22,16 +22,16 @@ enum Tab: Int, Identifiable, Hashable, CaseIterable, Codable { rawValue } - static func loggedOutTab() -> [Tab] { + static func loggedOutTab() -> [AppTab] { [.timeline, .settings] } - static func visionOSTab() -> [Tab] { + static func visionOSTab() -> [AppTab] { [.profile, .timeline, .notifications, .mentions, .explore, .post, .settings] } @ViewBuilder - func makeContentView(selectedTab: Binding, popToRootTab: Binding) -> some View { + func makeContentView(selectedTab: Binding, popToRootTab: Binding) -> some View { switch self { case .timeline: TimelineTab(popToRootTab: popToRootTab) @@ -168,7 +168,7 @@ enum Tab: Int, Identifiable, Hashable, CaseIterable, Codable { @Observable class SidebarTabs { struct SidedebarTab: Hashable, Codable { - let tab: Tab + let tab: AppTab var enabled: Bool } @@ -202,7 +202,7 @@ class SidebarTabs { } } - func isEnabled(_ tab: Tab) -> Bool { + func isEnabled(_ tab: AppTab) -> Bool { tabs.first(where: { $0.tab.id == tab.id })?.enabled == true } @@ -219,45 +219,45 @@ class iOSTabs { } class Storage { - @AppStorage(TabEntries.first.rawValue) var firstTab = Tab.timeline - @AppStorage(TabEntries.second.rawValue) var secondTab = Tab.notifications - @AppStorage(TabEntries.third.rawValue) var thirdTab = Tab.explore - @AppStorage(TabEntries.fourth.rawValue) var fourthTab = Tab.links - @AppStorage(TabEntries.fifth.rawValue) var fifthTab = Tab.profile + @AppStorage(TabEntries.first.rawValue) var firstTab = AppTab.timeline + @AppStorage(TabEntries.second.rawValue) var secondTab = AppTab.notifications + @AppStorage(TabEntries.third.rawValue) var thirdTab = AppTab.explore + @AppStorage(TabEntries.fourth.rawValue) var fourthTab = AppTab.links + @AppStorage(TabEntries.fifth.rawValue) var fifthTab = AppTab.profile } private let storage = Storage() public static let shared = iOSTabs() - var tabs: [Tab] { + var tabs: [AppTab] { [firstTab, secondTab, thirdTab, fourthTab, fifthTab] } - var firstTab: Tab { + var firstTab: AppTab { didSet { storage.firstTab = firstTab } } - var secondTab: Tab { + var secondTab: AppTab { didSet { storage.secondTab = secondTab } } - var thirdTab: Tab { + var thirdTab: AppTab { didSet { storage.thirdTab = thirdTab } } - var fourthTab: Tab { + var fourthTab: AppTab { didSet { storage.fourthTab = fourthTab } } - var fifthTab: Tab { + var fifthTab: AppTab { didSet { storage.fifthTab = fifthTab } diff --git a/IceCubesApp/App/Tabs/Timeline/TimelineTab.swift b/IceCubesApp/App/Tabs/Timeline/TimelineTab.swift index f4b9852b..7c4469ed 100644 --- a/IceCubesApp/App/Tabs/Timeline/TimelineTab.swift +++ b/IceCubesApp/App/Tabs/Timeline/TimelineTab.swift @@ -18,7 +18,7 @@ struct TimelineTab: View { @Environment(UserPreferences.self) private var preferences @Environment(Client.self) private var client @State private var routerPath = RouterPath() - @Binding var popToRootTab: Tab + @Binding var popToRootTab: AppTab @State private var didAppear: Bool = false @State private var timeline: TimelineFilter = .home @@ -33,7 +33,7 @@ struct TimelineTab: View { private let canFilterTimeline: Bool - init(popToRootTab: Binding, timeline: TimelineFilter? = nil) { + init(popToRootTab: Binding, timeline: TimelineFilter? = nil) { canFilterTimeline = timeline == nil _popToRootTab = popToRootTab _timeline = .init(initialValue: timeline ?? .home) diff --git a/IceCubesAppIntents/TabIntent.swift b/IceCubesAppIntents/TabIntent.swift index b4bb34ae..7f6fd107 100644 --- a/IceCubesAppIntents/TabIntent.swift +++ b/IceCubesAppIntents/TabIntent.swift @@ -35,7 +35,7 @@ enum TabEnum: String, AppEnum, Sendable { .post: .init(title: "New post")] } - var toAppTab: Tab { + var toAppTab: AppTab { switch self { case .timeline: .timeline diff --git a/IceCubesAppWidgetsExtension/AccountWidget/AccountWidget.swift b/IceCubesAppWidgetsExtension/AccountWidget/AccountWidget.swift index 315bb925..2f85ad9c 100644 --- a/IceCubesAppWidgetsExtension/AccountWidget/AccountWidget.swift +++ b/IceCubesAppWidgetsExtension/AccountWidget/AccountWidget.swift @@ -23,8 +23,11 @@ struct AccountWidgetProvider: AppIntentTimelineProvider { } private func fetchAccount(configuration: AccountWidgetConfiguration) async -> Account { - let client = Client(server: configuration.account.account.server, - oauthToken: configuration.account.account.oauthToken) + guard let account = configuration.account else { + return .placeholder() + } + let client = Client(server: account.account.server, + oauthToken: account.account.oauthToken) do { let account: Account = try await client.get(endpoint: Accounts.verifyCredentials) return account diff --git a/IceCubesAppWidgetsExtension/AccountWidget/AccountWidgetConfiguration.swift b/IceCubesAppWidgetsExtension/AccountWidget/AccountWidgetConfiguration.swift index a21f5201..ffd48730 100644 --- a/IceCubesAppWidgetsExtension/AccountWidget/AccountWidgetConfiguration.swift +++ b/IceCubesAppWidgetsExtension/AccountWidget/AccountWidgetConfiguration.swift @@ -6,7 +6,7 @@ struct AccountWidgetConfiguration: WidgetConfigurationIntent { static let description = IntentDescription("Choose the account for this widget") @Parameter(title: "Account") - var account: AppAccountEntity + var account: AppAccountEntity? } extension AccountWidgetConfiguration { diff --git a/IceCubesAppWidgetsExtension/HashtagPostsWidget/HashtagPostsWidget.swift b/IceCubesAppWidgetsExtension/HashtagPostsWidget/HashtagPostsWidget.swift index 82b020d6..42652ed8 100644 --- a/IceCubesAppWidgetsExtension/HashtagPostsWidget/HashtagPostsWidget.swift +++ b/IceCubesAppWidgetsExtension/HashtagPostsWidget/HashtagPostsWidget.swift @@ -29,9 +29,16 @@ struct HashtagPostsWidgetProvider: AppIntentTimelineProvider { private func timeline(for configuration: HashtagPostsWidgetConfiguration, context: Context) async -> Timeline { do { - let timeline: TimelineFilter = .hashtag(tag: configuration.hashgtag, accountId: nil) + guard let account = configuration.account, let hashgtag = configuration.hashgtag else { + return Timeline(entries: [.init(date: Date(), + title: "#Mastodon", + statuses: [], + images: [:])], + policy: .atEnd) + } + let timeline: TimelineFilter = .hashtag(tag: hashgtag, accountId: nil) let statuses = await loadStatuses(for: timeline, - account: configuration.account, + account: account, widgetFamily: context.family) let images = try await loadImages(urls: statuses.map { $0.account.avatar }) return Timeline(entries: [.init(date: Date(), diff --git a/IceCubesAppWidgetsExtension/HashtagPostsWidget/HashtagPostsWidgetConfiguration.swift b/IceCubesAppWidgetsExtension/HashtagPostsWidget/HashtagPostsWidgetConfiguration.swift index 74d767a9..df01d4d0 100644 --- a/IceCubesAppWidgetsExtension/HashtagPostsWidget/HashtagPostsWidgetConfiguration.swift +++ b/IceCubesAppWidgetsExtension/HashtagPostsWidget/HashtagPostsWidgetConfiguration.swift @@ -6,10 +6,10 @@ struct HashtagPostsWidgetConfiguration: WidgetConfigurationIntent { static let description = IntentDescription("Choose the account and hashtag for this widget") @Parameter(title: "Account") - var account: AppAccountEntity + var account: AppAccountEntity? @Parameter(title: "Hashtag") - var hashgtag: String + var hashgtag: String? } extension HashtagPostsWidgetConfiguration { diff --git a/IceCubesAppWidgetsExtension/LatestPostsWidget/LatestPostsWidget.swift b/IceCubesAppWidgetsExtension/LatestPostsWidget/LatestPostsWidget.swift index a79111b5..b7df808e 100644 --- a/IceCubesAppWidgetsExtension/LatestPostsWidget/LatestPostsWidget.swift +++ b/IceCubesAppWidgetsExtension/LatestPostsWidget/LatestPostsWidget.swift @@ -18,7 +18,7 @@ struct LatestPostsWidgetProvider: AppIntentTimelineProvider { return entry } return .init(date: Date(), - title: configuration.timeline.timeline.title, + title: configuration.timeline?.timeline.title ?? "", statuses: [], images: [:]) } @@ -29,17 +29,24 @@ struct LatestPostsWidgetProvider: AppIntentTimelineProvider { private func timeline(for configuration: LatestPostsWidgetConfiguration, context: Context) async -> Timeline { do { - let statuses = await loadStatuses(for: configuration.timeline.timeline, - account: configuration.account, + guard let timeline = configuration.timeline, let account = configuration.account else { + return Timeline(entries: [.init(date: Date(), + title: "", + statuses: [], + images: [:])], + policy: .atEnd) + } + let statuses = await loadStatuses(for: timeline.timeline, + account: account, widgetFamily: context.family) let images = try await loadImages(urls: statuses.map { $0.account.avatar }) return Timeline(entries: [.init(date: Date(), - title: configuration.timeline.timeline.title, + title: timeline.timeline.title, statuses: statuses, images: images)], policy: .atEnd) } catch { return Timeline(entries: [.init(date: Date(), - title: configuration.timeline.timeline.title, + title: configuration.timeline?.timeline.title ?? "", statuses: [], images: [:])], policy: .atEnd) diff --git a/IceCubesAppWidgetsExtension/LatestPostsWidget/LatestPostsWidgetConfiguration.swift b/IceCubesAppWidgetsExtension/LatestPostsWidget/LatestPostsWidgetConfiguration.swift index e4dbed5b..4c30704b 100644 --- a/IceCubesAppWidgetsExtension/LatestPostsWidget/LatestPostsWidgetConfiguration.swift +++ b/IceCubesAppWidgetsExtension/LatestPostsWidget/LatestPostsWidgetConfiguration.swift @@ -6,10 +6,10 @@ struct LatestPostsWidgetConfiguration: WidgetConfigurationIntent { static let description = IntentDescription("Choose the account and timeline for this widget") @Parameter(title: "Account") - var account: AppAccountEntity + var account: AppAccountEntity? @Parameter(title: "Timeline") - var timeline: TimelineFilterEntity + var timeline: TimelineFilterEntity? } extension LatestPostsWidgetConfiguration { diff --git a/IceCubesAppWidgetsExtension/ListsWidget/ListsWidget.swift b/IceCubesAppWidgetsExtension/ListsWidget/ListsWidget.swift index 1cc488b2..42cebd3f 100644 --- a/IceCubesAppWidgetsExtension/ListsWidget/ListsWidget.swift +++ b/IceCubesAppWidgetsExtension/ListsWidget/ListsWidget.swift @@ -29,13 +29,20 @@ struct ListsWidgetProvider: AppIntentTimelineProvider { private func timeline(for configuration: ListsWidgetConfiguration, context: Context) async -> Timeline { do { - let timeline: TimelineFilter = .list(list: configuration.timeline.list) - let statuses = await loadStatuses(for: timeline, - account: configuration.account, + guard let account = configuration.account, let timeline = configuration.timeline else { + return Timeline(entries: [.init(date: Date(), + title: "List name", + statuses: [], + images: [:])], + policy: .atEnd) + } + let filter: TimelineFilter = .list(list: timeline.list) + let statuses = await loadStatuses(for: filter, + account: account, widgetFamily: context.family) let images = try await loadImages(urls: statuses.map { $0.account.avatar }) return Timeline(entries: [.init(date: Date(), - title: timeline.title, + title: filter.title, statuses: statuses, images: images)], policy: .atEnd) } catch { diff --git a/IceCubesAppWidgetsExtension/ListsWidget/ListsWidgetConfiguration.swift b/IceCubesAppWidgetsExtension/ListsWidget/ListsWidgetConfiguration.swift index ebe4e0db..22f019aa 100644 --- a/IceCubesAppWidgetsExtension/ListsWidget/ListsWidgetConfiguration.swift +++ b/IceCubesAppWidgetsExtension/ListsWidget/ListsWidgetConfiguration.swift @@ -6,10 +6,10 @@ struct ListsWidgetConfiguration: WidgetConfigurationIntent { static let description = IntentDescription("Choose the account and list for this widget") @Parameter(title: "Account") - var account: AppAccountEntity + var account: AppAccountEntity? @Parameter(title: "List") - var timeline: ListEntity + var timeline: ListEntity? } extension ListsWidgetConfiguration { diff --git a/IceCubesAppWidgetsExtension/MentionWidget/MentionWidget.swift b/IceCubesAppWidgetsExtension/MentionWidget/MentionWidget.swift index a3d2616b..500a7bd8 100644 --- a/IceCubesAppWidgetsExtension/MentionWidget/MentionWidget.swift +++ b/IceCubesAppWidgetsExtension/MentionWidget/MentionWidget.swift @@ -29,8 +29,15 @@ struct MentionsWidgetProvider: AppIntentTimelineProvider { private func timeline(for configuration: MentionsWidgetConfiguration, context _: Context) async -> Timeline { do { - let client = Client(server: configuration.account.account.server, - oauthToken: configuration.account.account.oauthToken) + guard let account = configuration.account else { + return Timeline(entries: [.init(date: Date(), + title: "Mentions", + statuses: [], + images: [:])], + policy: .atEnd) + } + let client = Client(server: account.account.server, + oauthToken: account.account.oauthToken) var excludedTypes = Models.Notification.NotificationType.allCases excludedTypes.removeAll(where: { $0 == .mention }) let notifications: [Models.Notification] = diff --git a/IceCubesAppWidgetsExtension/MentionWidget/MentionWidgetConfiguration.swift b/IceCubesAppWidgetsExtension/MentionWidget/MentionWidgetConfiguration.swift index 9dbe64a3..3e04faba 100644 --- a/IceCubesAppWidgetsExtension/MentionWidget/MentionWidgetConfiguration.swift +++ b/IceCubesAppWidgetsExtension/MentionWidget/MentionWidgetConfiguration.swift @@ -6,7 +6,7 @@ struct MentionsWidgetConfiguration: WidgetConfigurationIntent { static let description = IntentDescription("Choose the account for this widget") @Parameter(title: "Account") - var account: AppAccountEntity + var account: AppAccountEntity? } extension MentionsWidgetConfiguration {