From 6d0407cd970be3207456c6ff85327356ecd6b1fd Mon Sep 17 00:00:00 2001 From: GalvinGao Date: Wed, 11 Oct 2023 16:10:34 -0400 Subject: [PATCH] fix(app): widget compat on ios 17 --- ios/App/App.xcodeproj/project.pbxproj | 8 ++++---- .../xcschemes/PenguinWidgetExtension.xcscheme | 2 +- ios/App/PenguinWidget/PenguinWidget.swift | 19 +++++++++++++++++++ .../Variants/AccessoryRectangularView.swift | 4 ++++ .../Variants/LargeWidgetView.swift | 2 +- .../Variants/MediumWidgetView.swift | 2 +- .../Variants/SmallWidgetView.swift | 2 +- .../PenguinWidget/Views/ItemStatsView.swift | 2 +- package.json | 2 +- 9 files changed, 33 insertions(+), 10 deletions(-) diff --git a/ios/App/App.xcodeproj/project.pbxproj b/ios/App/App.xcodeproj/project.pbxproj index 2a0d2109..e646d495 100644 --- a/ios/App/App.xcodeproj/project.pbxproj +++ b/ios/App/App.xcodeproj/project.pbxproj @@ -853,7 +853,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 3.13.10; + MARKETING_VERSION = 3.13.11; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = io.penguinstats.app.PenguinWidget; @@ -885,7 +885,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 3.13.10; + MARKETING_VERSION = 3.13.11; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = io.penguinstats.app.PenguinWidget; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -1083,7 +1083,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 3.13.10; + MARKETING_VERSION = 3.13.11; OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\""; PRODUCT_BUNDLE_IDENTIFIER = io.penguinstats.app; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -1115,7 +1115,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 3.13.10; + MARKETING_VERSION = 3.13.11; PRODUCT_BUNDLE_IDENTIFIER = io.penguinstats.app; PRODUCT_NAME = "$(TARGET_NAME)"; SUPPORTS_MACCATALYST = NO; diff --git a/ios/App/App.xcodeproj/xcshareddata/xcschemes/PenguinWidgetExtension.xcscheme b/ios/App/App.xcodeproj/xcshareddata/xcschemes/PenguinWidgetExtension.xcscheme index 85989907..52dfb0c2 100644 --- a/ios/App/App.xcodeproj/xcshareddata/xcschemes/PenguinWidgetExtension.xcscheme +++ b/ios/App/App.xcodeproj/xcshareddata/xcschemes/PenguinWidgetExtension.xcscheme @@ -100,7 +100,7 @@ diff --git a/ios/App/PenguinWidget/PenguinWidget.swift b/ios/App/PenguinWidget/PenguinWidget.swift index e110f0d1..582d3413 100644 --- a/ios/App/PenguinWidget/PenguinWidget.swift +++ b/ios/App/PenguinWidget/PenguinWidget.swift @@ -31,6 +31,7 @@ struct PenguinWidget: Widget { .configurationDisplayName("SiteStatsWidgetName") .description("SiteStatsWidgetDesc") .adaptedSupportedFamilies() + .adaptedContentMarginsDisabled() } } @@ -49,6 +50,14 @@ extension WidgetConfiguration { ]) } } + + func adaptedContentMarginsDisabled() -> some WidgetConfiguration { + if #available(iOSApplicationExtension 15, *) { + return self.contentMarginsDisabled() + } else { + return self + } + } } extension View { @@ -59,6 +68,16 @@ extension View { self } } + + func widgetBackground(_ backgroundView: some View) -> some View { + if #available(iOSApplicationExtension 17.0, *) { + return containerBackground(for: .widget) { + backgroundView + } + } else { + return background(backgroundView) + } + } } struct FadeMasked: ViewModifier { diff --git a/ios/App/PenguinWidget/Variants/AccessoryRectangularView.swift b/ios/App/PenguinWidget/Variants/AccessoryRectangularView.swift index a5d2450a..0354ee0d 100644 --- a/ios/App/PenguinWidget/Variants/AccessoryRectangularView.swift +++ b/ios/App/PenguinWidget/Variants/AccessoryRectangularView.swift @@ -48,6 +48,10 @@ struct AccessoryRectangularView: View { .foregroundColor(Color("Secondary").opacity(0.8)) } } + .widgetURL(Routes.generate( + zoneId: stage.zoneId, + stageId: stage.stageId)) + .widgetBackground(Color.clear) } } diff --git a/ios/App/PenguinWidget/Variants/LargeWidgetView.swift b/ios/App/PenguinWidget/Variants/LargeWidgetView.swift index 3caeaac2..3b821ca7 100644 --- a/ios/App/PenguinWidget/Variants/LargeWidgetView.swift +++ b/ios/App/PenguinWidget/Variants/LargeWidgetView.swift @@ -25,7 +25,7 @@ struct LargeWidgetView: View { WidgetFooter(server: stats.server) } .padding() - .background(Color("Background")) + .widgetBackground(Color("Background")) } } diff --git a/ios/App/PenguinWidget/Variants/MediumWidgetView.swift b/ios/App/PenguinWidget/Variants/MediumWidgetView.swift index 65ec0e1d..11f64dfc 100644 --- a/ios/App/PenguinWidget/Variants/MediumWidgetView.swift +++ b/ios/App/PenguinWidget/Variants/MediumWidgetView.swift @@ -39,7 +39,7 @@ struct MediumWidgetView: View { entry.preferences.theme.overlayView(widgetFamily: family), alignment: .bottom ) - .background(entry.preferences.theme.backgroundColor) + .widgetBackground(entry.preferences.theme.backgroundColor) .if(entry.preferences.theme.forcedColorScheme != nil) { view in view.environment(\.colorScheme, entry.preferences.theme.forcedColorScheme!) } diff --git a/ios/App/PenguinWidget/Variants/SmallWidgetView.swift b/ios/App/PenguinWidget/Variants/SmallWidgetView.swift index 3e7e941a..71c76f1f 100644 --- a/ios/App/PenguinWidget/Variants/SmallWidgetView.swift +++ b/ios/App/PenguinWidget/Variants/SmallWidgetView.swift @@ -42,7 +42,7 @@ struct SmallWidgetView : View { entry.preferences.theme.overlayView(widgetFamily: family), alignment: .bottom ) - .background(entry.preferences.theme.backgroundColor) + .widgetBackground(entry.preferences.theme.backgroundColor) .widgetURL(Routes.generate( zoneId: entry.stats.stages[0].zoneId, stageId: entry.stats.stages[0].stageId)) diff --git a/ios/App/PenguinWidget/Views/ItemStatsView.swift b/ios/App/PenguinWidget/Views/ItemStatsView.swift index 335eb0cf..69cc0e3f 100644 --- a/ios/App/PenguinWidget/Views/ItemStatsView.swift +++ b/ios/App/PenguinWidget/Views/ItemStatsView.swift @@ -18,7 +18,7 @@ struct ItemStatsView: View { var body: some View { HStack(alignment: .center, spacing: 4) { Link(destination: Routes.generate(itemId: item.id)) { - Group { + HStack(alignment: .center, spacing: 4) { item.image() .frame(width: 20, height: 20, alignment: .center) diff --git a/package.json b/package.json index 575ae01e..afeff6e7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "penguin-stats-frontend", - "version": "3.13.10", + "version": "3.13.11", "private": true, "author": "Penguin Statistics Contributors (https://github.com/orgs/penguin-statistics/people)", "scripts": {