Skip to content

Commit

Permalink
Merge pull request wikimedia#4701 from wikimedia/T346810
Browse files Browse the repository at this point in the history
Fix widget presentation on iOS 17
  • Loading branch information
tonisevener authored Dec 14, 2023
2 parents 970c853 + ac556ba commit f19c64b
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 6 deletions.
13 changes: 13 additions & 0 deletions Widgets/Utilities/View+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,17 @@ extension View {
}
}

/// Sets container background of the view to `Color.clear` if on iOS 17
/// - Returns: a modified `View` with the iOS 17 container background modifier applied if needed
@ViewBuilder
func clearWidgetContainerBackground() -> some View {
if #available(iOS 17.0, *) {
self.containerBackground(for: .widget) {
Color.clear
}
} else {
self
}
}

}
3 changes: 3 additions & 0 deletions Widgets/Widgets/FeaturedArticleWidget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ struct FeaturedArticleWidget: Widget {
.configurationDisplayName(FeaturedArticleWidget.LocalizedStrings.widgetTitle)
.description(FeaturedArticleWidget.LocalizedStrings.widgetDescription)
.supportedFamilies([.systemSmall, .systemMedium, .systemLarge])
.contentMarginsDisabled()
.containerBackgroundRemovable(false)
}
}

Expand Down Expand Up @@ -278,6 +280,7 @@ struct FeaturedArticleView: View {

var body: some View {
widgetBody
.clearWidgetContainerBackground()
.widgetURL(entry.contentURL)
.environment(\.layoutDirection, entry.layoutDirection)
.flipsForRightToLeftLayoutDirection(true)
Expand Down
1 change: 1 addition & 0 deletions Widgets/Widgets/OnThisDayView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ struct OnThisDayView: View {
}
.overlay(errorBox)
.environment(\.layoutDirection, entry.isRTLLanguage ? .rightToLeft : .leftToRight)
.clearWidgetContainerBackground()
.widgetURL(entry.contentURL)
}

Expand Down
2 changes: 2 additions & 0 deletions Widgets/Widgets/OnThisDayWidget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ struct OnThisDayWidget: Widget {
.configurationDisplayName(CommonStrings.onThisDayTitle)
.description(WMFLocalizedString("widget-onthisday-description", value: "Explore what happened on this day in history.", comment: "Description for 'On this day' view in iOS widget gallery"))
.supportedFamilies([.systemSmall, .systemMedium, .systemLarge])
.contentMarginsDisabled()
.containerBackgroundRemovable(false)
}
}

Expand Down
3 changes: 3 additions & 0 deletions Widgets/Widgets/PictureOfTheDayWidget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ struct PictureOfTheDayWidget: Widget {
.configurationDisplayName(PictureOfTheDayWidget.LocalizedStrings.widgetTitle)
.description(PictureOfTheDayWidget.LocalizedStrings.widgetDescription)
.supportedFamilies([.systemSmall, .systemMedium, .systemLarge])
.contentMarginsDisabled()
.containerBackgroundRemovable(false)
}
}

Expand Down Expand Up @@ -172,6 +174,7 @@ struct PictureOfTheDayView: View {
.overlay(PictureOfTheDayOverlayView(entry: entry), alignment: .bottomLeading)
}
}
.clearWidgetContainerBackground()
.widgetURL(entry.contentURL)
}

Expand Down
3 changes: 3 additions & 0 deletions Widgets/Widgets/TopReadWidget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ struct TopReadWidget: Widget {
.configurationDisplayName(LocalizedStrings.widgetTitle)
.description(LocalizedStrings.widgetDescription)
.supportedFamilies([.systemSmall, .systemMedium, .systemLarge])
.contentMarginsDisabled()
.containerBackgroundRemovable(false)
}
}

Expand Down Expand Up @@ -171,6 +173,7 @@ struct TopReadView: View {
.widgetURL(entry?.rankedElements.first?.articleURL)
}
}
.clearWidgetContainerBackground()
.environment(\.layoutDirection, entry?.contentLayoutDirection ?? .leftToRight)
.flipsForRightToLeftLayoutDirection(true)
}
Expand Down
6 changes: 0 additions & 6 deletions Wikipedia.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
00021DEA24D48EFE00476F97 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 00021DE924D48EFE00476F97 /* Assets.xcassets */; };
00021DEE24D48EFE00476F97 /* WidgetsExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 00021DE124D48EFD00476F97 /* WidgetsExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
00021E0424D4A42A00476F97 /* PictureOfTheDayWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00021E0324D4A42A00476F97 /* PictureOfTheDayWidget.swift */; };
00097D5C29660FF2000B3514 /* View+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 006D273424D8BAFB00947551 /* View+Extensions.swift */; };
00097D5D29660FF3000B3514 /* View+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 006D273424D8BAFB00947551 /* View+Extensions.swift */; };
00097D5E29660FF3000B3514 /* View+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 006D273424D8BAFB00947551 /* View+Extensions.swift */; };
0010F93927A49C7700D77848 /* HorizontalSpacerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0010F93827A49C7700D77848 /* HorizontalSpacerView.swift */; };
0010F93A27A49C7700D77848 /* HorizontalSpacerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0010F93827A49C7700D77848 /* HorizontalSpacerView.swift */; };
0010F93B27A49C7700D77848 /* HorizontalSpacerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0010F93827A49C7700D77848 /* HorizontalSpacerView.swift */; };
Expand Down Expand Up @@ -10445,7 +10442,6 @@
D837CC37231FE9CC00BA6130 /* ThemeableViewController.swift in Sources */,
83C0688E292EEDAF00DF1403 /* TalkPageViewController+TalkPageFormattingToolbar.swift in Sources */,
7A73B48221E54B4200249E09 /* SectionEditorNavigationItemController.swift in Sources */,
00097D5C29660FF2000B3514 /* View+Extensions.swift in Sources */,
B0FFFB2A21C9BED1001E787E /* TextFormattingButton.swift in Sources */,
7AF6F76622395BEC00949393 /* EditingWelcomeViewController.swift in Sources */,
B0524B51214854E900D8FD8D /* DescriptionWelcomeContainerViewController.swift in Sources */,
Expand Down Expand Up @@ -11389,7 +11385,6 @@
00841DE524477805003CF74A /* AppTabBarDelegate.swift in Sources */,
D8CE25271E698E2400DAE2E0 /* WMFChangePasswordViewController.swift in Sources */,
D8B166861FD97A0500097D8B /* ViewController.swift in Sources */,
00097D5E29660FF3000B3514 /* View+Extensions.swift in Sources */,
B0421AA3206991F500C22630 /* SavedTabBarItemProgressBadgeManager.swift in Sources */,
7A6ED52220ADBF950001849F /* LoginFunnel.swift in Sources */,
83CA612B20D1675800EF0C4A /* ExploreCardViewController.swift in Sources */,
Expand Down Expand Up @@ -11978,7 +11973,6 @@
D8EC3E1A1E9BDA35006712EB /* UIVIewController+WMFCommonRotationSupport.swift in Sources */,
83E776A520FFA4D700E26A47 /* DetailTransition.swift in Sources */,
6771299524FF775E00E89CA5 /* ArticleAsLivingDocLargeEventCollectionViewCell.swift in Sources */,
00097D5D29660FF3000B3514 /* View+Extensions.swift in Sources */,
D8EC3E1B1E9BDA35006712EB /* (null) in Sources */,
B0C7A0851F710EB1008415E7 /* WMFWelcomeAnalyticsAnimationBackgroundView.swift in Sources */,
D8EC3E1D1E9BDA35006712EB /* WMFTitleInsetRespectingButton.m in Sources */,
Expand Down

0 comments on commit f19c64b

Please sign in to comment.