diff --git a/Common/UserDefaultKeys.swift b/Common/UserDefaultKeys.swift index 8b137891..e69de29b 100644 --- a/Common/UserDefaultKeys.swift +++ b/Common/UserDefaultKeys.swift @@ -1 +0,0 @@ - diff --git a/Common/View Modifier/DismissableSheet.swift b/Common/View Modifier/DismissableSheet.swift index ed2253a9..ca765d7f 100644 --- a/Common/View Modifier/DismissableSheet.swift +++ b/Common/View Modifier/DismissableSheet.swift @@ -11,6 +11,7 @@ import SwiftUI struct DismissableSheet: ViewModifier where Item: Identifiable { @Binding var sheet: Item? + var title = "sys.done" var todoOnDismiss: () -> Void @@ -46,6 +47,7 @@ extension View { struct DismissableBoolSheet: ViewModifier { @Binding var isSheetShow: Bool + var title: String = "sys.done" var todoOnDismiss: () -> Void @@ -129,9 +131,9 @@ struct SheetCaller: View { @State private var sansFinishButton: Bool + @State private var isSheetShown = false + @ViewBuilder private let destination: () -> D @ViewBuilder private let label: () -> L - - @State private var isSheetShown = false } diff --git a/Features/CharacterInventory/CharacterInventoryView.swift b/Features/CharacterInventory/CharacterInventoryView.swift index 5f104d42..5f094f2c 100644 --- a/Features/CharacterInventory/CharacterInventoryView.swift +++ b/Features/CharacterInventory/CharacterInventoryView.swift @@ -164,15 +164,15 @@ struct CharacterInventoryView: View { case star4 = "app.characters.filter.4star" } - private let data: MiHoYoAPI.CharacterInventory - private let isMiyousheUID: Bool - @State private var allAvatarListDisplayType: AllAvatarListDisplayType = .all @State private var expanded: Bool = false @State private var containerSize: CGSize = .init(width: 320, height: 320) @StateObject private var orientation = DeviceOrientation() @Environment(\.dismiss) private var dismiss + private let data: MiHoYoAPI.CharacterInventory + private let isMiyousheUID: Bool + private var characterStats: LocalizedStringKey { let aaa = data.avatarList.count let bbb = data.avatarList.filter { $0.rarity == 5 }.count @@ -329,10 +329,10 @@ struct AvatarListItem: View { // MARK: Private + @State private var condensed: Bool + private let avatar: MiHoYoAPI.CharacterInventory.HYAvatar private let limited: Bool - @State private var condensed: Bool - @Default(.useRealCharacterNames) private var useRealName: Bool } diff --git a/Features/Daily Note Widget/GI Style Rectangular Widget/GIStyleRectangularWidgetView.swift b/Features/Daily Note Widget/GI Style Rectangular Widget/GIStyleRectangularWidgetView.swift index edaa1faa..a98a9941 100644 --- a/Features/Daily Note Widget/GI Style Rectangular Widget/GIStyleRectangularWidgetView.swift +++ b/Features/Daily Note Widget/GI Style Rectangular Widget/GIStyleRectangularWidgetView.swift @@ -12,8 +12,14 @@ import SwiftUI struct GIStyleRectangularWidgetView: View { @Environment(\.colorScheme) var colorScheme + let entry: GIStyleEntry + var actualColorScheme: ColorScheme { + guard entry.configuration.textColor != .primary else { return colorScheme } + return entry.configuration.textColor == .white ? .light : .dark + } + var body: some View { Group { switch entry.dailyNoteResult { @@ -36,11 +42,6 @@ struct GIStyleRectangularWidgetView: View { .edgesIgnoringSafeArea(.all) .environment(\.colorScheme, actualColorScheme) } - - var actualColorScheme: ColorScheme { - guard entry.configuration.textColor != .primary else { return colorScheme } - return entry.configuration.textColor == .white ? .light : .dark - } } // MARK: - WidgetGIStyleSuccessView diff --git a/Features/Daily Note Widget/GI Style Square Widget/GIStyleSquareWidgetView.swift b/Features/Daily Note Widget/GI Style Square Widget/GIStyleSquareWidgetView.swift index 52e8164c..28b02dc6 100644 --- a/Features/Daily Note Widget/GI Style Square Widget/GIStyleSquareWidgetView.swift +++ b/Features/Daily Note Widget/GI Style Square Widget/GIStyleSquareWidgetView.swift @@ -12,8 +12,14 @@ import SwiftUI struct GIStyleSquareWidgetView: View { @Environment(\.colorScheme) var colorScheme + let entry: GIStyleEntry + var actualColorScheme: ColorScheme { + guard entry.configuration.textColor != .primary else { return colorScheme } + return entry.configuration.textColor == .white ? .light : .dark + } + var body: some View { Group { switch entry.dailyNoteResult { @@ -37,11 +43,6 @@ struct GIStyleSquareWidgetView: View { .edgesIgnoringSafeArea(.all) .environment(\.colorScheme, actualColorScheme) } - - var actualColorScheme: ColorScheme { - guard entry.configuration.textColor != .primary else { return colorScheme } - return entry.configuration.textColor == .white ? .light : .dark - } } // MARK: - WidgetGIStyleSuccessView diff --git a/Features/Daily Note Widget/Timeline Provider/LockscreenTimelineProvider.swift b/Features/Daily Note Widget/Timeline Provider/LockscreenTimelineProvider.swift index eea47650..be8f0573 100644 --- a/Features/Daily Note Widget/Timeline Provider/LockscreenTimelineProvider.swift +++ b/Features/Daily Note Widget/Timeline Provider/LockscreenTimelineProvider.swift @@ -61,7 +61,7 @@ struct LockscreenTimelineProvider: IntentTimelineProvider, HasDefaultAccount { in context: Context, completion: @escaping (Timeline) -> Void ) { - Task { + Task { @MainActor in var entries: [Entry] = [] let account: Account? = { diff --git a/Features/Daily Note/View/InAppDailyNoteCardView.swift b/Features/Daily Note/View/InAppDailyNoteCardView.swift index 73a70097..802aaffb 100644 --- a/Features/Daily Note/View/InAppDailyNoteCardView.swift +++ b/Features/Daily Note/View/InAppDailyNoteCardView.swift @@ -59,10 +59,10 @@ struct InAppDailyNoteCardView: View { // MARK: Private - private let refreshSubject: PassthroughSubject - @StateObject private var dailyNoteViewModel: DailyNoteViewModel + private let refreshSubject: PassthroughSubject + private var account: Account { dailyNoteViewModel.account } diff --git a/Features/Gacha/View/AccountGachaDetailView.swift b/Features/Gacha/View/AccountGachaDetailView.swift index 2d126ab5..839e4309 100644 --- a/Features/Gacha/View/AccountGachaDetailView.swift +++ b/Features/Gacha/View/AccountGachaDetailView.swift @@ -104,17 +104,6 @@ private struct GachaItemDetail: View { // MARK: Internal - var body: some View { - if !filteredGachaItemsWithDrawCount.isEmpty { - ForEach(filteredGachaItemsWithDrawCount, id: \.0.id) { item, drawCount in - GachaItemBar(item: item, drawCount: drawCount, showTime: showTime) - } - } else { - Text("gacha.account_detail.detail.no_data") - .foregroundColor(.secondary) - } - } - var filteredGachaItemsWithDrawCount: [(GachaItemMO, Int)] { /// 补记:这里已经用 Query Predicate 筛检过了,所以 drawCounts 计算结果无误。 let drawCounts = calculateGachaItemsDrawCount(gachaItemsResult) @@ -131,11 +120,23 @@ private struct GachaItemDetail: View { } } + var body: some View { + if !filteredGachaItemsWithDrawCount.isEmpty { + ForEach(filteredGachaItemsWithDrawCount, id: \.0.id) { item, drawCount in + GachaItemBar(item: item, drawCount: drawCount, showTime: showTime) + } + } else { + Text("gacha.account_detail.detail.no_data") + .foregroundColor(.secondary) + } + } + // MARK: Private + @FetchRequest private var gachaItemsResult: FetchedResults + private var showTime: Bool - @FetchRequest private var gachaItemsResult: FetchedResults private let rankFilter: RankFilter } diff --git a/Features/Gacha/View/AccountGachaView.swift b/Features/Gacha/View/AccountGachaView.swift index 90442de7..730395f9 100644 --- a/Features/Gacha/View/AccountGachaView.swift +++ b/Features/Gacha/View/AccountGachaView.swift @@ -90,14 +90,6 @@ private struct GachaSmallChart: View { } } - var body: some View { - if fiveStarItems.isEmpty { - Text("gacha.account_detail.small_chart.no_data") - } else { - chart() - } - } - var colors: [Color] { fiveStarItems.map { _, count in switch count { @@ -111,6 +103,14 @@ private struct GachaSmallChart: View { } } + var body: some View { + if fiveStarItems.isEmpty { + Text("gacha.account_detail.small_chart.no_data") + } else { + chart() + } + } + @ViewBuilder func chart() -> some View { ScrollView(.horizontal) { @@ -265,10 +265,11 @@ private struct GachaStatisticSectionView: View { return fmt }() + @FetchRequest private var gachaItemsResult: FetchedResults + private let gachaType: GachaType @Default(.useGuestGachaEvaluator) private var useGuestGachaEvaluator: Bool - @FetchRequest private var gachaItemsResult: FetchedResults private var itemsWithDrawCount: [(GachaItemMO, drawCount: Int)] { Array(zip(gachaItemsResult, calculateGachaItemsDrawCount(gachaItemsResult))) diff --git a/Features/Gacha/View/GachaChartView.swift b/Features/Gacha/View/GachaChartView.swift index 74e7e0e7..46fa9339 100644 --- a/Features/Gacha/View/GachaChartView.swift +++ b/Features/Gacha/View/GachaChartView.swift @@ -89,13 +89,13 @@ private struct GachaItemChart: View { private typealias ItemPair = (GachaItemMO, count: Int) + @FetchRequest private var gachaItemsResult: FetchedResults + @Default(.useGuestGachaEvaluator) private var useGuestGachaEvaluator: Bool @Default(.useRealCharacterNames) private var useRealCharacterNames: Bool private let gachaType: GachaType - @FetchRequest private var gachaItemsResult: FetchedResults - private var items: [ItemPair] { Array(zip(gachaItemsResult, calculateGachaItemsDrawCount(gachaItemsResult))) } @@ -104,10 +104,6 @@ private struct GachaItemChart: View { useGuestGachaEvaluator ? "UI_EmotionIcon5" : "Pom-Pom_Sticker_32" } - private func extract5Stars(_ source: [ItemPair]) -> [ItemPair] { - source.filter { $0.0.rank == .five } - } - @ViewBuilder private func subChart( givenItems: [ItemPair], @@ -148,6 +144,10 @@ private struct GachaItemChart: View { .chartLegend(.hidden) } + private func extract5Stars(_ source: [ItemPair]) -> [ItemPair] { + source.filter { $0.0.rank == .five } + } + private func matchedItems( among source: [ItemPair], with value: String diff --git a/Features/Gacha/View/SRGF/ExportGachaView.swift b/Features/Gacha/View/SRGF/ExportGachaView.swift index 10970b82..03703b79 100644 --- a/Features/Gacha/View/SRGF/ExportGachaView.swift +++ b/Features/Gacha/View/SRGF/ExportGachaView.swift @@ -123,8 +123,6 @@ struct ExportGachaView: View { @State private var isSucceedAlertShown: Bool = false @State private var isFailureAlertShown: Bool = false - private let compactLayout: Bool - @Environment(\.managedObjectContext) private var viewContext @Environment(\.dismiss) private var dismiss @@ -140,6 +138,8 @@ struct ExportGachaView: View { @State private var uigfJson: UIGFv4? @State private var currentFormat: UIGFFormat = .uigfv4 + private let compactLayout: Bool + private var currentDocument: GachaDocument? { switch currentFormat { case .uigfv4: uigfJson?.asDocument @@ -192,6 +192,34 @@ struct ExportGachaView: View { } } + @ViewBuilder + private func accountPicker() -> some View { + Picker("app.gacha.account.select.title", selection: $params.uid) { + Group { + ForEach(accountPickerPairs, id: \.tag) { value, tag in + Text(value).tag(tag) + } + } + } + } + + @ViewBuilder + private func postAlertMessage() -> some View { + switch alert { + case let .succeed(url): Text("gacha.export.fileSavedTo:\(url)") + case let .failure(message): Text(verbatim: "⚠︎ \(message)") + case nil: EmptyView() + } + } + + @ViewBuilder + private func exportButton() -> some View { + Button("app.gacha.data.export.button") { + exportButtonClicked(format: currentFormat) + } + .disabled(params.uid == nil && currentFormat == .srgfv1) + } + private func exportButtonClicked(format: UIGFFormat) { switch format { case .uigfv4: @@ -233,17 +261,6 @@ struct ExportGachaView: View { } } - @ViewBuilder - private func accountPicker() -> some View { - Picker("app.gacha.account.select.title", selection: $params.uid) { - Group { - ForEach(accountPickerPairs, id: \.tag) { value, tag in - Text(value).tag(tag) - } - } - } - } - private func firstAccount(uid: String) -> Account? { accounts.first(where: { $0.uid! == uid }) } @@ -256,23 +273,6 @@ struct ExportGachaView: View { alert = .failure(message: failure.localizedDescription) } } - - @ViewBuilder - private func postAlertMessage() -> some View { - switch alert { - case let .succeed(url): Text("gacha.export.fileSavedTo:\(url)") - case let .failure(message): Text(verbatim: "⚠︎ \(message)") - case nil: EmptyView() - } - } - - @ViewBuilder - private func exportButton() -> some View { - Button("app.gacha.data.export.button") { - exportButtonClicked(format: currentFormat) - } - .disabled(params.uid == nil && currentFormat == .srgfv1) - } } extension ExportGachaView { diff --git a/Features/Gacha/View/SRGF/ImportGachaView.swift b/Features/Gacha/View/SRGF/ImportGachaView.swift index 34da5444..d159f9d7 100644 --- a/Features/Gacha/View/SRGF/ImportGachaView.swift +++ b/Features/Gacha/View/SRGF/ImportGachaView.swift @@ -474,6 +474,7 @@ private struct PopFileButton: View { private struct StatusView: View { @Binding var status: ImportStatus + @ViewBuilder var pendingForImportView: () -> V var body: some View { @@ -496,6 +497,7 @@ private struct StatusView: View { private struct FailureView: View { @Binding var status: ImportStatus + let errorMessage: String var body: some View { @@ -512,6 +514,7 @@ private struct FailureView: View { private struct SucceedView: View { @Binding var status: ImportStatus + let infoMsgs: [ImportSucceedInfo] var body: some View { diff --git a/Features/Manage Accounts/CreateAccountSheetView.swift b/Features/Manage Accounts/CreateAccountSheetView.swift index 64c8975a..ca2515e8 100644 --- a/Features/Manage Accounts/CreateAccountSheetView.swift +++ b/Features/Manage Accounts/CreateAccountSheetView.swift @@ -78,6 +78,54 @@ struct CreateAccountSheetView: View { } } + @ViewBuilder + func menuForManagingHoYoLabAccounts() -> some View { + Menu { + OtherSettingsView.linksForManagingHoYoLabAccounts + } label: { + Text("account.login.manageLink.shortened") + } + } + + @ViewBuilder + func pendingView() -> some View { + Group { + Section { + RequireLoginView(unsavedCookie: $account.cookie, unsavedFP: $account.deviceFingerPrint, region: $region) + } footer: { + VStack(alignment: .leading) { + HStack { + Text("account.login.manual.1") + NavigationLink { + AccountDetailView(account: account) + } label: { + Text("account.login.manual.2") + .font(.footnote) + } + } + Divider().padding(.vertical) + ExplanationView() + } + } + } + .onChange(of: account.cookie) { _ in + if account.hasValidCookie { + status = .gotCookie + } + } + .interactiveDismissDisabled() + } + + @ViewBuilder + func gotCookieView() -> some View { + ProgressView() + } + + @ViewBuilder + func gotAccountView() -> some View { + EditAccountView(account: account, accountsForSelected: accountsForSelected) + } + func saveAccount() { guard account.isValid else { saveAccountError = .missingFieldError( @@ -128,54 +176,6 @@ struct CreateAccountSheetView: View { } } - @ViewBuilder - func menuForManagingHoYoLabAccounts() -> some View { - Menu { - OtherSettingsView.linksForManagingHoYoLabAccounts - } label: { - Text("account.login.manageLink.shortened") - } - } - - @ViewBuilder - func pendingView() -> some View { - Group { - Section { - RequireLoginView(unsavedCookie: $account.cookie, unsavedFP: $account.deviceFingerPrint, region: $region) - } footer: { - VStack(alignment: .leading) { - HStack { - Text("account.login.manual.1") - NavigationLink { - AccountDetailView(account: account) - } label: { - Text("account.login.manual.2") - .font(.footnote) - } - } - Divider().padding(.vertical) - ExplanationView() - } - } - } - .onChange(of: account.cookie) { _ in - if account.hasValidCookie { - status = .gotCookie - } - } - .interactiveDismissDisabled() - } - - @ViewBuilder - func gotCookieView() -> some View { - ProgressView() - } - - @ViewBuilder - func gotAccountView() -> some View { - EditAccountView(account: account, accountsForSelected: accountsForSelected) - } - // MARK: Private @EnvironmentObject private var alertToastVariable: AlertToastVariable diff --git a/Features/Manage Accounts/ManageAccountsView.swift b/Features/Manage Accounts/ManageAccountsView.swift index 677360d0..6845c6a5 100644 --- a/Features/Manage Accounts/ManageAccountsView.swift +++ b/Features/Manage Accounts/ManageAccountsView.swift @@ -21,6 +21,14 @@ class AlertToastVariable: ObservableObject { struct ManageAccountsView: View { // MARK: Internal + var isShown: Binding { + .init { + sheetType != nil + } set: { newValue in + if !newValue { sheetType = nil } + } + } + var body: some View { List { Section { @@ -107,14 +115,6 @@ struct ManageAccountsView: View { .environment(\.editMode, $isEditMode) } - var isShown: Binding { - .init { - sheetType != nil - } set: { newValue in - if !newValue { sheetType = nil } - } - } - // MARK: Private private enum SheetType: Identifiable, Hashable { diff --git a/Features/Manage Accounts/SubView/TestAccountSectionView.swift b/Features/Manage Accounts/SubView/TestAccountSectionView.swift index 3bd1ddf3..41e0b931 100644 --- a/Features/Manage Accounts/SubView/TestAccountSectionView.swift +++ b/Features/Manage Accounts/SubView/TestAccountSectionView.swift @@ -43,6 +43,27 @@ struct TestAccountSectionView: View { } } + @ViewBuilder + func buttonIcon() -> some View { + Group { + switch status { + case .succeeded: + Image(systemSymbol: .checkmarkCircle) + .foregroundColor(.green) + case .failure: + Image(systemSymbol: .xmarkCircle) + .foregroundColor(.red) + case .testing: + ProgressView() + case .verificationNeeded: + Image(systemSymbol: .questionmarkCircle) + .foregroundColor(.yellow) + default: + EmptyView() + } + } + } + func doTest() { withAnimation { status = .testing @@ -71,27 +92,6 @@ struct TestAccountSectionView: View { } } - @ViewBuilder - func buttonIcon() -> some View { - Group { - switch status { - case .succeeded: - Image(systemSymbol: .checkmarkCircle) - .foregroundColor(.green) - case .failure: - Image(systemSymbol: .xmarkCircle) - .foregroundColor(.red) - case .testing: - ProgressView() - case .verificationNeeded: - Image(systemSymbol: .questionmarkCircle) - .foregroundColor(.yellow) - default: - EmptyView() - } - } - } - // MARK: Private private enum TestStatus: Identifiable, Equatable { diff --git a/HSRPizzaHelper Watch App/WatchHomeView.swift b/HSRPizzaHelper Watch App/WatchHomeView.swift index 5b0f84a3..d9a2989f 100644 --- a/HSRPizzaHelper Watch App/WatchHomeView.swift +++ b/HSRPizzaHelper Watch App/WatchHomeView.swift @@ -105,10 +105,10 @@ struct InAppDailyNoteCardView: View { // MARK: Private - private let refreshSubject: PassthroughSubject - @StateObject private var dailyNoteViewModel: DailyNoteViewModel + private let refreshSubject: PassthroughSubject + private var account: Account { dailyNoteViewModel.account } diff --git a/HSRPizzaHelper/ContentView.swift b/HSRPizzaHelper/ContentView.swift index fffc7a9a..a7d30b27 100644 --- a/HSRPizzaHelper/ContentView.swift +++ b/HSRPizzaHelper/ContentView.swift @@ -17,6 +17,15 @@ import SwiftUI struct ContentView: View { // MARK: Internal + var index: Binding { Binding( + get: { selection }, + set: { + selection = $0 + Defaults[.appTabIndex] = $0 + UserDefaults.hsrSuite.synchronize() + } + ) } + var body: some View { TabView(selection: index) { HomeView() @@ -64,15 +73,6 @@ struct ContentView: View { .initializeApp() } - var index: Binding { Binding( - get: { selection }, - set: { - selection = $0 - Defaults[.appTabIndex] = $0 - UserDefaults.hsrSuite.synchronize() - } - ) } - // MARK: Private @State private var selection: Int = { diff --git a/HSRPizzaHelper/View/DetailPortalView.swift b/HSRPizzaHelper/View/DetailPortalView.swift index 1b2bd50f..dc39fe16 100644 --- a/HSRPizzaHelper/View/DetailPortalView.swift +++ b/HSRPizzaHelper/View/DetailPortalView.swift @@ -381,14 +381,14 @@ private struct AccountHeaderView: View { // MARK: Private - private let additionalView: () -> T - - private let refreshAction: (() -> Void)? - @Binding private var profile: EnkaHSR.QueryRelated.DetailInfo? @StateObject private var vmDPV: DetailPortalViewModel = .init() + private let additionalView: () -> T + + private let refreshAction: (() -> Void)? + private var uidStr: String { guard let strUid = guardedProfile?.uid.description else { return "……" } return "UID: \(strUid)" @@ -518,6 +518,13 @@ private struct PlayerDetailSection: View { vmDPV.enkaProfileStatus } + var isUpdating: Bool { + switch vmDPV.enkaProfileStatus { + case .progress: true + default: false + } + } + @ViewBuilder var currentShowCase: some View { if let profile = vmDPV.currentEnkaProfile { profile.asView(theDB: vmDPV.enkaDB) @@ -526,13 +533,6 @@ private struct PlayerDetailSection: View { } } - var isUpdating: Bool { - switch vmDPV.enkaProfileStatus { - case .progress: true - default: false - } - } - var body: some View { Section { let theCase = currentShowCase diff --git a/HSRPizzaHelper/View/SettingView.swift b/HSRPizzaHelper/View/SettingView.swift index da348fcc..49c0edd6 100644 --- a/HSRPizzaHelper/View/SettingView.swift +++ b/HSRPizzaHelper/View/SettingView.swift @@ -102,10 +102,6 @@ struct SettingView: View { @Environment(\.horizontalSizeClass) private var horizontalSizeClass: UserInterfaceSizeClass? - private func callMUISettings() { - UIApplication.shared.open(URL(string: UIApplication.openSettingsURLString)!) - } - @ViewBuilder private func navigationDetail(selection: Binding) -> some View { NavigationStack { @@ -131,6 +127,10 @@ struct SettingView: View { } } } + + private func callMUISettings() { + UIApplication.shared.open(URL(string: UIApplication.openSettingsURLString)!) + } } // MARK: - OtherSettingsView diff --git a/Packages/EnkaKitHSR/Sources/EnkaSwiftUIViews/AllCharacterPhotoSpecimenView.swift b/Packages/EnkaKitHSR/Sources/EnkaSwiftUIViews/AllCharacterPhotoSpecimenView.swift index 2ed3861f..ca76e06b 100644 --- a/Packages/EnkaKitHSR/Sources/EnkaSwiftUIViews/AllCharacterPhotoSpecimenView.swift +++ b/Packages/EnkaKitHSR/Sources/EnkaSwiftUIViews/AllCharacterPhotoSpecimenView.swift @@ -13,6 +13,15 @@ public struct CharSpecimen: Identifiable, Hashable { public let id: String + @ViewBuilder + public func render(size: Double, cutType: IDPhotoView.IconType = .cutShoulder) -> some View { + if let first = IDPhotoView(pid: id, size, cutType, forceRender: true) { + first + } else { + IDPhotoFallbackView(pid: id, size, cutType) + } + } + @ViewBuilder public static func renderAllSpecimen( scroll: Bool, @@ -37,15 +46,6 @@ public struct CharSpecimen: Identifiable, Hashable { } } - @ViewBuilder - public func render(size: Double, cutType: IDPhotoView.IconType = .cutShoulder) -> some View { - if let first = IDPhotoView(pid: id, size, cutType, forceRender: true) { - first - } else { - IDPhotoFallbackView(pid: id, size, cutType) - } - } - // MARK: Internal static func allSpecimens(supplementalIDs: [String]? = nil) -> [Self] { diff --git a/Packages/EnkaKitHSR/Sources/EnkaSwiftUIViews/AvatarShowCaseView.swift b/Packages/EnkaKitHSR/Sources/EnkaSwiftUIViews/AvatarShowCaseView.swift index 76c3ccc7..bd9a5227 100644 --- a/Packages/EnkaKitHSR/Sources/EnkaSwiftUIViews/AvatarShowCaseView.swift +++ b/Packages/EnkaKitHSR/Sources/EnkaSwiftUIViews/AvatarShowCaseView.swift @@ -142,14 +142,15 @@ public struct AvatarShowCaseView: View { @State private var selection: Int = 0 - private let onClose: (() -> Void)? - @State private var showTabViewIndex: Bool = false @State private var showingCharacterIdentifier: Int @ObservedObject private var profile: EnkaHSR.ProfileSummarized @StateObject private var orientation = DeviceOrientation() + + private let onClose: (() -> Void)? + private let bottomSpacerHeight: CGFloat = 20 private var avatar: EnkaHSR.AvatarSummarized? { diff --git a/Packages/EnkaKitHSR/Sources/EnkaSwiftUIViews/CaseQuerySection.swift b/Packages/EnkaKitHSR/Sources/EnkaSwiftUIViews/CaseQuerySection.swift index 7aecaad1..87c5e209 100644 --- a/Packages/EnkaKitHSR/Sources/EnkaSwiftUIViews/CaseQuerySection.swift +++ b/Packages/EnkaKitHSR/Sources/EnkaSwiftUIViews/CaseQuerySection.swift @@ -90,9 +90,10 @@ public struct CaseQuerySection: View { @State var givenUID: String = "" - var focused: FocusState.Binding? @FocusState var backupFocus: Bool + var focused: FocusState.Binding? + var avatarAssetName: String { delegate.currentInfo?.accountPhotoFileNameStem(theDB: theDB) ?? EnkaHSR.QueryRelated.DetailInfo.nullPhotoAssetName @@ -126,9 +127,10 @@ public struct CaseQuerySection: View { // MARK: Private - private var theDB: EnkaHSR.EnkaDB @StateObject private var delegate: Coordinator = .init() + private var theDB: EnkaHSR.EnkaDB + private var isUIDValid: Bool { guard let givenUIDInt = Int(givenUID) else { return false } return (100_000_000 ... 9_999_999_999).contains(givenUIDInt) diff --git a/Packages/EnkaKitHSR/Sources/EnkaSwiftUIViews/IDPhotoView.swift b/Packages/EnkaKitHSR/Sources/EnkaSwiftUIViews/IDPhotoView.swift index f419a09b..d44faa43 100644 --- a/Packages/EnkaKitHSR/Sources/EnkaSwiftUIViews/IDPhotoView.swift +++ b/Packages/EnkaKitHSR/Sources/EnkaSwiftUIViews/IDPhotoView.swift @@ -194,17 +194,38 @@ public struct IDPhotoView: View { @Environment(\.colorScheme) var colorScheme - var coreBody: some View { + var proposedSize: CGSize { switch iconType { - case .asCard: return AnyView(cardView) - default: return AnyView(circleIconView) + case .asCard: return .init(width: size * 0.74, height: size) + default: return .init(width: size, height: size) } } - var proposedSize: CGSize { + var elementColor: Color { + var opacity: Double = 1 + switch lifePath { + case .abundance: opacity = 0.4 + case .hunt: opacity = 0.35 + default: break + } + return EnkaHSR.Sputnik.sharedDB.characters[pid]?.element.themeColor.suiColor.opacity(opacity) ?? .clear + } + + var baseWindowBGColor: Color { + switch colorScheme { + case .dark: + return .init(cgColor: .init(red: 0.20, green: 0.20, blue: 0.20, alpha: 1.00)) + case .light: + return .init(cgColor: .init(red: 0.80, green: 0.80, blue: 0.80, alpha: 1.00)) + @unknown default: + return .gray + } + } + + var coreBody: some View { switch iconType { - case .asCard: return .init(width: size * 0.74, height: size) - default: return .init(width: size, height: size) + case .asCard: return AnyView(cardView) + default: return AnyView(circleIconView) } } @@ -272,27 +293,6 @@ public struct IDPhotoView: View { .background(baseWindowBGColor) } - var elementColor: Color { - var opacity: Double = 1 - switch lifePath { - case .abundance: opacity = 0.4 - case .hunt: opacity = 0.35 - default: break - } - return EnkaHSR.Sputnik.sharedDB.characters[pid]?.element.themeColor.suiColor.opacity(opacity) ?? .clear - } - - var baseWindowBGColor: Color { - switch colorScheme { - case .dark: - return .init(cgColor: .init(red: 0.20, green: 0.20, blue: 0.20, alpha: 1.00)) - case .light: - return .init(cgColor: .init(red: 0.80, green: 0.80, blue: 0.80, alpha: 1.00)) - @unknown default: - return .gray - } - } - // MARK: Private private class Coordinator: ObservableObject { @@ -366,17 +366,28 @@ struct IDPhotoFallbackView: View { @Environment(\.colorScheme) var colorScheme - var coreBody: some View { + var proposedSize: CGSize { switch iconType { - case .asCard: return AnyView(cardView) - default: return AnyView(circleIconView) + case .asCard: return .init(width: size * 0.74, height: size) + default: return .init(width: size, height: size) } } - var proposedSize: CGSize { + var baseWindowBGColor: Color { + switch colorScheme { + case .dark: + return .init(cgColor: .init(red: 0.20, green: 0.20, blue: 0.20, alpha: 1.00)) + case .light: + return .init(cgColor: .init(red: 0.80, green: 0.80, blue: 0.80, alpha: 1.00)) + @unknown default: + return .gray + } + } + + var coreBody: some View { switch iconType { - case .asCard: return .init(width: size * 0.74, height: size) - default: return .init(width: size, height: size) + case .asCard: return AnyView(cardView) + default: return AnyView(circleIconView) } } @@ -432,17 +443,6 @@ struct IDPhotoFallbackView: View { .background(baseWindowBGColor) } - var baseWindowBGColor: Color { - switch colorScheme { - case .dark: - return .init(cgColor: .init(red: 0.20, green: 0.20, blue: 0.20, alpha: 1.00)) - case .light: - return .init(cgColor: .init(red: 0.80, green: 0.80, blue: 0.80, alpha: 1.00)) - @unknown default: - return .gray - } - } - // MARK: Private private class Coordinator: ObservableObject { diff --git a/Packages/EnkaKitHSR/Sources/EnkaSwiftUIViews/ShowCaseListView.swift b/Packages/EnkaKitHSR/Sources/EnkaSwiftUIViews/ShowCaseListView.swift index 739126e4..d0f85a2a 100644 --- a/Packages/EnkaKitHSR/Sources/EnkaSwiftUIViews/ShowCaseListView.swift +++ b/Packages/EnkaKitHSR/Sources/EnkaSwiftUIViews/ShowCaseListView.swift @@ -118,9 +118,10 @@ public struct ShowCaseListView: View { // MARK: Internal @State var showingCharacterIdentifier: Int? - @Default(.animateOnCallingCharacterShowcase) var animateOnCallingCharacterShowcase: Bool @ObservedObject var profile: EnkaHSR.ProfileSummarized + @Default(.animateOnCallingCharacterShowcase) var animateOnCallingCharacterShowcase: Bool + @ViewBuilder func fullScreenCover(id enkaId: Int) -> some View { AvatarShowCaseView( diff --git a/Packages/GachaKitHSR/Sources/GachaKitHSR/GachaMetaDBImpl/GMDB_UserDefaults.swift b/Packages/GachaKitHSR/Sources/GachaKitHSR/GachaMetaDBImpl/GMDB_UserDefaults.swift index 5d220992..4e941366 100644 --- a/Packages/GachaKitHSR/Sources/GachaKitHSR/GachaMetaDBImpl/GMDB_UserDefaults.swift +++ b/Packages/GachaKitHSR/Sources/GachaKitHSR/GachaMetaDBImpl/GMDB_UserDefaults.swift @@ -30,6 +30,6 @@ extension Defaults.Keys { ) } -extension GachaItemMetadata: _DefaultsSerializable {} +extension GachaItemMetadata: @retroactive _DefaultsSerializable {} #endif