Skip to content

Commit

Permalink
fix(app): widget compat on ios 17
Browse files Browse the repository at this point in the history
  • Loading branch information
GalvinGao committed Oct 11, 2023
1 parent e456901 commit 6d0407c
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 10 deletions.
8 changes: 4 additions & 4 deletions ios/App/App.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)";
Expand Down Expand Up @@ -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)";
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
</EnvironmentVariable>
<EnvironmentVariable
key = "_XCWidgetFamily"
value = "medium"
value = "accessoryRectangular"
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
Expand Down
19 changes: 19 additions & 0 deletions ios/App/PenguinWidget/PenguinWidget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ struct PenguinWidget: Widget {
.configurationDisplayName("SiteStatsWidgetName")
.description("SiteStatsWidgetDesc")
.adaptedSupportedFamilies()
.adaptedContentMarginsDisabled()
}
}

Expand All @@ -49,6 +50,14 @@ extension WidgetConfiguration {
])
}
}

func adaptedContentMarginsDisabled() -> some WidgetConfiguration {
if #available(iOSApplicationExtension 15, *) {
return self.contentMarginsDisabled()
} else {
return self
}
}
}

extension View {
Expand All @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions ios/App/PenguinWidget/Variants/AccessoryRectangularView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
2 changes: 1 addition & 1 deletion ios/App/PenguinWidget/Variants/LargeWidgetView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct LargeWidgetView: View {
WidgetFooter(server: stats.server)
}
.padding()
.background(Color("Background"))
.widgetBackground(Color("Background"))
}
}

Expand Down
2 changes: 1 addition & 1 deletion ios/App/PenguinWidget/Variants/MediumWidgetView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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!)
}
Expand Down
2 changes: 1 addition & 1 deletion ios/App/PenguinWidget/Variants/SmallWidgetView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion ios/App/PenguinWidget/Views/ItemStatsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "penguin-stats-frontend",
"version": "3.13.10",
"version": "3.13.11",
"private": true,
"author": "Penguin Statistics Contributors <contributors@penguin-stats.io> (https://github.com/orgs/penguin-statistics/people)",
"scripts": {
Expand Down

0 comments on commit 6d0407c

Please sign in to comment.