diff --git a/Mastodon.xcodeproj/project.pbxproj b/Mastodon.xcodeproj/project.pbxproj index 4db188f6f..067ac0559 100644 --- a/Mastodon.xcodeproj/project.pbxproj +++ b/Mastodon.xcodeproj/project.pbxproj @@ -45,6 +45,7 @@ 2A728134297EA9D8004138C5 /* WidgetExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 2A728120297EA9D7004138C5 /* WidgetExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 2A72813F297EC762004138C5 /* WidgetExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A72813E297EC762004138C5 /* WidgetExtension.swift */; }; 2A82294F29262EE000D2A1F7 /* AppContext+NextAccount.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A82294E29262EE000D2A1F7 /* AppContext+NextAccount.swift */; }; + 2A84443C2B84F68100071C5B /* View+WidgetBackground.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A84443B2B84F68100071C5B /* View+WidgetBackground.swift */; }; 2A86A14629892944007F1062 /* MultiFollowersCountIntentHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A86A14529892944007F1062 /* MultiFollowersCountIntentHandler.swift */; }; 2A86A14929892B3A007F1062 /* MultiFollowersCountWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A86A14829892B3A007F1062 /* MultiFollowersCountWidget.swift */; }; 2A86A14B2989326E007F1062 /* MultiFollowersCountWidgetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A86A14A2989326E007F1062 /* MultiFollowersCountWidgetView.swift */; }; @@ -656,6 +657,7 @@ 2A72812F297EA9D8004138C5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 2A72813E297EC762004138C5 /* WidgetExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidgetExtension.swift; sourceTree = ""; }; 2A82294E29262EE000D2A1F7 /* AppContext+NextAccount.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AppContext+NextAccount.swift"; sourceTree = ""; }; + 2A84443B2B84F68100071C5B /* View+WidgetBackground.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "View+WidgetBackground.swift"; sourceTree = ""; }; 2A86A14529892944007F1062 /* MultiFollowersCountIntentHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiFollowersCountIntentHandler.swift; sourceTree = ""; }; 2A86A14829892B3A007F1062 /* MultiFollowersCountWidget.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiFollowersCountWidget.swift; sourceTree = ""; }; 2A86A14A2989326E007F1062 /* MultiFollowersCountWidgetView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiFollowersCountWidgetView.swift; sourceTree = ""; }; @@ -1491,6 +1493,7 @@ 2AE202A9297FDDF500F66E55 /* WidgetExtension.entitlements */, 2A72813E297EC762004138C5 /* WidgetExtension.swift */, 2A728126297EA9D7004138C5 /* WidgetExtensionBundle.swift */, + 2A84443B2B84F68100071C5B /* View+WidgetBackground.swift */, 2AB50120299243FB00346092 /* WidgetExtension.intentdefinition */, 2A72812D297EA9D8004138C5 /* Assets.xcassets */, 2A72812F297EA9D8004138C5 /* Info.plist */, @@ -3570,6 +3573,7 @@ 2AB5011E299243FB00346092 /* WidgetExtension.intentdefinition in Sources */, 2A86A14B2989326E007F1062 /* MultiFollowersCountWidgetView.swift in Sources */, 2A72813F297EC762004138C5 /* WidgetExtension.swift in Sources */, + 2A84443C2B84F68100071C5B /* View+WidgetBackground.swift in Sources */, 2A86A14929892B3A007F1062 /* MultiFollowersCountWidget.swift in Sources */, 2A33AB662982C4AF008A7FB1 /* FollowersCountWidgetView.swift in Sources */, 2A9D0664298C048800BF38CB /* LatestFollowersWidget.swift in Sources */, diff --git a/WidgetExtension/Variants/FollowersCount/FollowersCountWidget.swift b/WidgetExtension/Variants/FollowersCount/FollowersCountWidget.swift index 2c2c53ffd..b7bcf1942 100644 --- a/WidgetExtension/Variants/FollowersCount/FollowersCountWidget.swift +++ b/WidgetExtension/Variants/FollowersCount/FollowersCountWidget.swift @@ -65,6 +65,7 @@ struct FollowersCountWidget: Widget { .configurationDisplayName(L10n.Widget.FollowersCount.configurationDisplayName) .description(L10n.Widget.FollowersCount.configurationDescription) .supportedFamilies(availableFamilies) + .contentMarginsDisabled() // Disable excessive margins (only effective for iOS >= 17.0 } } diff --git a/WidgetExtension/Variants/FollowersCount/FollowersCountWidgetView.swift b/WidgetExtension/Variants/FollowersCount/FollowersCountWidgetView.swift index 2c781b36e..84d48ffd3 100644 --- a/WidgetExtension/Variants/FollowersCount/FollowersCountWidgetView.swift +++ b/WidgetExtension/Variants/FollowersCount/FollowersCountWidgetView.swift @@ -34,6 +34,7 @@ struct FollowersCountWidgetView: View { .multilineTextAlignment(.center) .font(.caption) .padding(.all, 20) + .emptyWidgetBackground() } } @@ -66,6 +67,7 @@ struct FollowersCountWidgetView: View { .padding(.vertical, 16) Spacer() } + .emptyWidgetBackground() } private func viewForSmallWidgetYesChart(_ account: FollowersEntryAccountable) -> some View { @@ -125,6 +127,7 @@ struct FollowersCountWidgetView: View { } } .padding(.top, 16) + .emptyWidgetBackground() } private func viewForAccessoryRectangular(_ account: FollowersEntryAccountable) -> some View { @@ -144,11 +147,11 @@ struct FollowersCountWidgetView: View { } Spacer() } + .emptyWidgetBackground() } private func viewForAccessoryCircular(_ account :FollowersEntryAccountable) -> some View { ZStack { - AccessoryWidgetBackground() VStack { Image("BrandIcon") @@ -158,5 +161,6 @@ struct FollowersCountWidgetView: View { .truncationMode(.tail) } } + .widgetBackground(AccessoryWidgetBackground()) } } diff --git a/WidgetExtension/Variants/Hashtag/HashtagWidget.swift b/WidgetExtension/Variants/Hashtag/HashtagWidget.swift index 08ca4c77b..0545816fe 100644 --- a/WidgetExtension/Variants/Hashtag/HashtagWidget.swift +++ b/WidgetExtension/Variants/Hashtag/HashtagWidget.swift @@ -159,6 +159,7 @@ struct HashtagWidget: Widget { .configurationDisplayName(L10n.Widget.Hashtag.Configuration.displayName) .description(L10n.Widget.Hashtag.Configuration.description) .supportedFamilies(availableFamilies) + .contentMarginsDisabled() // Disable excessive margins (only effective for iOS >= 17.0 } } diff --git a/WidgetExtension/Variants/Hashtag/HashtagWidgetView.swift b/WidgetExtension/Variants/Hashtag/HashtagWidgetView.swift index 39328f403..49cf4c357 100644 --- a/WidgetExtension/Variants/Hashtag/HashtagWidgetView.swift +++ b/WidgetExtension/Variants/Hashtag/HashtagWidgetView.swift @@ -65,6 +65,7 @@ struct HashtagWidgetView: View { } } .padding(EdgeInsets(top: 12, leading: 29, bottom: 12, trailing: 29)) + .emptyWidgetBackground() } private func viewForRectangularAccessory() -> some View { @@ -86,6 +87,7 @@ struct HashtagWidgetView: View { Text(statusWithColorHashtags: entry.hashtag.content, fontSize: 11, fontWeight: .medium) .lineLimit(3) } + .emptyWidgetBackground() } } diff --git a/WidgetExtension/Variants/LatestFollowers/LatestFollowersWidget.swift b/WidgetExtension/Variants/LatestFollowers/LatestFollowersWidget.swift index 456af2ebb..d4b0da773 100644 --- a/WidgetExtension/Variants/LatestFollowers/LatestFollowersWidget.swift +++ b/WidgetExtension/Variants/LatestFollowers/LatestFollowersWidget.swift @@ -72,6 +72,7 @@ struct LatestFollowersWidget: Widget { .configurationDisplayName(L10n.Widget.LatestFollowers.configurationDisplayName) .description(L10n.Widget.LatestFollowers.configurationDescription) .supportedFamilies(availableFamilies) + .contentMarginsDisabled() // Disable excessive margins (only effective for iOS >= 17.0 } } diff --git a/WidgetExtension/Variants/LatestFollowers/LatestFollowersWidgetView.swift b/WidgetExtension/Variants/LatestFollowers/LatestFollowersWidgetView.swift index c72d98162..570d34a77 100644 --- a/WidgetExtension/Variants/LatestFollowers/LatestFollowersWidgetView.swift +++ b/WidgetExtension/Variants/LatestFollowers/LatestFollowersWidgetView.swift @@ -34,6 +34,7 @@ struct LatestFollowersWidgetView: View { .multilineTextAlignment(.center) .font(.caption) .padding(.all, 20) + .emptyWidgetBackground() } } @@ -72,6 +73,7 @@ struct LatestFollowersWidgetView: View { } .padding(.horizontal, 20) .padding(.vertical, 16) + .emptyWidgetBackground() } private func viewForMediumWidget(_ accounts: [LatestFollowersEntryAccountable], lastUpdate: Date) -> some View { @@ -119,6 +121,7 @@ struct LatestFollowersWidgetView: View { } .padding(.horizontal, 20) .padding(.vertical, 16) + .emptyWidgetBackground() } } diff --git a/WidgetExtension/Variants/MultiFollowersCount/MultiFollowersCountWidget.swift b/WidgetExtension/Variants/MultiFollowersCount/MultiFollowersCountWidget.swift index 084a31f7c..59cd257bd 100644 --- a/WidgetExtension/Variants/MultiFollowersCount/MultiFollowersCountWidget.swift +++ b/WidgetExtension/Variants/MultiFollowersCount/MultiFollowersCountWidget.swift @@ -65,6 +65,7 @@ struct MultiFollowersCountWidget: Widget { .configurationDisplayName(L10n.Widget.MultipleFollowers.configurationDisplayName) .description(L10n.Widget.MultipleFollowers.configurationDescription) .supportedFamilies(availableFamilies) + .contentMarginsDisabled() // Disable excessive margins (only effective for iOS >= 17.0 } } diff --git a/WidgetExtension/Variants/MultiFollowersCount/MultiFollowersCountWidgetView.swift b/WidgetExtension/Variants/MultiFollowersCount/MultiFollowersCountWidgetView.swift index 6a519ad82..7718859df 100644 --- a/WidgetExtension/Variants/MultiFollowersCount/MultiFollowersCountWidgetView.swift +++ b/WidgetExtension/Variants/MultiFollowersCount/MultiFollowersCountWidgetView.swift @@ -25,6 +25,7 @@ struct MultiFollowersCountWidgetView: View { .multilineTextAlignment(.center) .font(.caption) .padding(.all, 20) + .emptyWidgetBackground() } } @@ -55,6 +56,7 @@ struct MultiFollowersCountWidgetView: View { Spacer() } .padding(.vertical, 16) + .emptyWidgetBackground() } private func viewForMediumWidget(_ accounts: [MultiFollowersEntryAccountable]) -> some View { @@ -89,5 +91,6 @@ struct MultiFollowersCountWidgetView: View { Spacer() } .padding(.vertical, 16) + .emptyWidgetBackground() } } diff --git a/WidgetExtension/View+WidgetBackground.swift b/WidgetExtension/View+WidgetBackground.swift new file mode 100644 index 000000000..55f18f22c --- /dev/null +++ b/WidgetExtension/View+WidgetBackground.swift @@ -0,0 +1,19 @@ +// Copyright © 2024 Mastodon gGmbH. All rights reserved. + +import SwiftUI + +extension View { + func emptyWidgetBackground() -> some View { + widgetBackground(EmptyView()) + } + + func widgetBackground(_ backgroundView: some View) -> some View { + if #available(iOSApplicationExtension 17.0, *) { + return containerBackground(for: .widget) { + backgroundView + } + } else { + return background(backgroundView) + } + } +}