From 1d8ce1070cf8874106ea80247483427a2dd4c106 Mon Sep 17 00:00:00 2001 From: Emerson Carpes Date: Fri, 3 May 2024 11:00:54 -0300 Subject: [PATCH 1/2] Revert "Revert "Merge pull request #152 from Adventech/feature/fixes-widgets-iOS17"" This reverts commit 230431f6caba5eafad28ff969744468fb3055a81. --- Sabbath School.xcodeproj/project.pbxproj | 16 ++++++++++++++ Widget/Extensions/ViewExtensions.swift | 21 +++++++++++++++++++ .../WidgetConfigurationExtensions.swift | 20 ++++++++++++++++++ .../LessonInfoWidget/LessonInfoWidget.swift | 1 + Widget/TodayWidget/FeaturedTodayWidget.swift | 1 + .../TodayWidget/FeaturedTodayWidgetView.swift | 2 +- Widget/TodayWidget/TodayWidget.swift | 1 + Widget/TodayWidget/TodayWidgetView.swift | 2 +- 8 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 Widget/Extensions/ViewExtensions.swift create mode 100644 Widget/Extensions/WidgetConfigurationExtensions.swift diff --git a/Sabbath School.xcodeproj/project.pbxproj b/Sabbath School.xcodeproj/project.pbxproj index 49db7aa5..9ab23590 100644 --- a/Sabbath School.xcodeproj/project.pbxproj +++ b/Sabbath School.xcodeproj/project.pbxproj @@ -86,6 +86,8 @@ 4E6B1A6C2AACDA42006B9283 /* NotificationCenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EE8B6F4284D1FAA003C1A46 /* NotificationCenter.swift */; }; 4E7B09892814CA3D00687C33 /* Encodable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E7B09882814CA3D00687C33 /* Encodable.swift */; }; 4E7B098C2814CA8A00687C33 /* Comparable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E7B098B2814CA8A00687C33 /* Comparable.swift */; }; + 4E7E4F3F2B79715D00920230 /* ViewExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E7E4F3E2B79715D00920230 /* ViewExtensions.swift */; }; + 4E7E4F412B7971A900920230 /* WidgetConfigurationExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E7E4F402B7971A900920230 /* WidgetConfigurationExtensions.swift */; }; 4E80B4232AC0A2DA002B6FBF /* SabbathSchoolTVApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E80B4222AC0A2DA002B6FBF /* SabbathSchoolTVApp.swift */; }; 4E80B4252AC0A2DA002B6FBF /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E80B4242AC0A2DA002B6FBF /* ContentView.swift */; }; 4E80B4272AC0A2DA002B6FBF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4E80B4262AC0A2DA002B6FBF /* Assets.xcassets */; }; @@ -393,6 +395,8 @@ 4E6409F427C5593A00A43D89 /* ScrollView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScrollView.swift; sourceTree = ""; }; 4E7B09882814CA3D00687C33 /* Encodable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Encodable.swift; sourceTree = ""; }; 4E7B098B2814CA8A00687C33 /* Comparable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Comparable.swift; sourceTree = ""; }; + 4E7E4F3E2B79715D00920230 /* ViewExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewExtensions.swift; sourceTree = ""; }; + 4E7E4F402B7971A900920230 /* WidgetConfigurationExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidgetConfigurationExtensions.swift; sourceTree = ""; }; 4E80B4202AC0A2D9002B6FBF /* SabbathSchoolTV.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SabbathSchoolTV.app; sourceTree = BUILT_PRODUCTS_DIR; }; 4E80B4222AC0A2DA002B6FBF /* SabbathSchoolTVApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SabbathSchoolTVApp.swift; sourceTree = ""; }; 4E80B4242AC0A2DA002B6FBF /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; @@ -867,6 +871,15 @@ path = Protocols; sourceTree = ""; }; + 4E7E4F3D2B796FB900920230 /* Extensions */ = { + isa = PBXGroup; + children = ( + 4E7E4F3E2B79715D00920230 /* ViewExtensions.swift */, + 4E7E4F402B7971A900920230 /* WidgetConfigurationExtensions.swift */, + ); + path = Extensions; + sourceTree = ""; + }; 4E80B4212AC0A2DA002B6FBF /* SabbathSchoolTV */ = { isa = PBXGroup; children = ( @@ -1621,6 +1634,7 @@ FE1E35012673C5DF00DAC2D6 /* Widget */ = { isa = PBXGroup; children = ( + 4E7E4F3D2B796FB900920230 /* Extensions */, FED6B2D22680262E007093CE /* LessonInfoWidget */, FE611A642674F9D2003CDDB5 /* TodayWidget */, FE44266F26751C160038A863 /* Resources */, @@ -2393,6 +2407,7 @@ FED6B3032680E0D9007093CE /* String.swift in Sources */, FE611AAB267500F5003CDDB5 /* Day.swift in Sources */, FEC92205267FB09100422F3D /* Color.swift in Sources */, + 4E7E4F3F2B79715D00920230 /* ViewExtensions.swift in Sources */, FE3FFA5426B11F4E0037539F /* QuarterlyGroup.swift in Sources */, FE611AAD267500F5003CDDB5 /* Comment.swift in Sources */, FE611AAC267500F5003CDDB5 /* LessonInfo.swift in Sources */, @@ -2424,6 +2439,7 @@ FED6B2EB268026D0007093CE /* LessonInfoWidget.swift in Sources */, FED6B2E6268026AE007093CE /* LessonInfoWidgetProvider.swift in Sources */, FED6B3122680E6F7007093CE /* WidgetInteractor.swift in Sources */, + 4E7E4F412B7971A900920230 /* WidgetConfigurationExtensions.swift in Sources */, 2F95D39F26C0B2E8008E6666 /* Audio.swift in Sources */, FEC9219B267E452800422F3D /* Helper.swift in Sources */, FED6B35826818BEA007093CE /* FeaturedTodayWidget.swift in Sources */, diff --git a/Widget/Extensions/ViewExtensions.swift b/Widget/Extensions/ViewExtensions.swift new file mode 100644 index 00000000..3636214c --- /dev/null +++ b/Widget/Extensions/ViewExtensions.swift @@ -0,0 +1,21 @@ +// +// ViewExtensions.swift +// WidgetExtension +// +// Created by Emerson Carpes on 11/02/24. +// Copyright © 2024 Adventech. All rights reserved. +// + +import SwiftUI + +extension View { + func widgetBackground(_ backgroundView: some View) -> some View { + if #available(iOSApplicationExtension 17.0, *) { + return containerBackground(for: .widget) { + backgroundView + } + } else { + return background(backgroundView) + } + } +} diff --git a/Widget/Extensions/WidgetConfigurationExtensions.swift b/Widget/Extensions/WidgetConfigurationExtensions.swift new file mode 100644 index 00000000..b82c92e7 --- /dev/null +++ b/Widget/Extensions/WidgetConfigurationExtensions.swift @@ -0,0 +1,20 @@ +// +// WidgetConfigurationExtensions.swift +// WidgetExtension +// +// Created by Emerson Carpes on 11/02/24. +// Copyright © 2024 Adventech. All rights reserved. +// + +import SwiftUI + +extension WidgetConfiguration { + func contentMarginsDisabledIfAvailable() -> some WidgetConfiguration { + if #available(iOSApplicationExtension 17.0, *) { + return self.contentMarginsDisabled() + } + else { + return self + } + } +} diff --git a/Widget/LessonInfoWidget/LessonInfoWidget.swift b/Widget/LessonInfoWidget/LessonInfoWidget.swift index 505f64d5..fbb78730 100644 --- a/Widget/LessonInfoWidget/LessonInfoWidget.swift +++ b/Widget/LessonInfoWidget/LessonInfoWidget.swift @@ -35,5 +35,6 @@ struct LessonInfoWidget: Widget { .configurationDisplayName("This week's lesson".localized()) .description("Preview and access Sabbath School lesson for this week".localized()) .supportedFamilies([.systemLarge]) + .contentMarginsDisabledIfAvailable() } } diff --git a/Widget/TodayWidget/FeaturedTodayWidget.swift b/Widget/TodayWidget/FeaturedTodayWidget.swift index 0c835f3a..ffaee17c 100644 --- a/Widget/TodayWidget/FeaturedTodayWidget.swift +++ b/Widget/TodayWidget/FeaturedTodayWidget.swift @@ -35,5 +35,6 @@ struct FeaturedTodayWidget: Widget { .configurationDisplayName("Today's lesson".localized()) .description("Get quick access the Sabbath School lesson for today, featuring the background image".localized()) .supportedFamilies([.systemSmall, .systemMedium]) + .contentMarginsDisabledIfAvailable() } } diff --git a/Widget/TodayWidget/FeaturedTodayWidgetView.swift b/Widget/TodayWidget/FeaturedTodayWidgetView.swift index eb82080c..f3e783f2 100644 --- a/Widget/TodayWidget/FeaturedTodayWidgetView.swift +++ b/Widget/TodayWidget/FeaturedTodayWidgetView.swift @@ -69,7 +69,7 @@ struct FeaturedTodayWidgetView : View { .padding(.bottom, 5) .padding(.leading, 20) .padding(.trailing, 20) - .background(Color.init(UIColor.baseBlue)) + .widgetBackground(Color.init(UIColor.baseBlue)) .foregroundColor(.white) .cornerRadius(11) .font(.system(size: 9, weight: .bold)) diff --git a/Widget/TodayWidget/TodayWidget.swift b/Widget/TodayWidget/TodayWidget.swift index 1a65964f..73a3e77e 100644 --- a/Widget/TodayWidget/TodayWidget.swift +++ b/Widget/TodayWidget/TodayWidget.swift @@ -35,5 +35,6 @@ struct TodayWidget: Widget { .configurationDisplayName("Today's lesson".localized()) .description("Get quick access the Sabbath School lesson for today".localized()) .supportedFamilies([.systemSmall, .systemMedium]) + .contentMarginsDisabledIfAvailable() } } diff --git a/Widget/TodayWidget/TodayWidgetView.swift b/Widget/TodayWidget/TodayWidgetView.swift index d5602ff4..207e676d 100644 --- a/Widget/TodayWidget/TodayWidgetView.swift +++ b/Widget/TodayWidget/TodayWidgetView.swift @@ -62,7 +62,7 @@ struct TodayWidgetView : View { .padding(.bottom, 5) .padding(.leading, 20) .padding(.trailing, 20) - .background(Color.init(UIColor.baseBlue)) + .widgetBackground(Color.init(UIColor.baseBlue)) .foregroundColor(.white) .cornerRadius(11) .font(.system(size: 9, weight: .bold)) From b9f54ea8e0304e3860835af85a3a0c2118090d66 Mon Sep 17 00:00:00 2001 From: Emerson Carpes Date: Fri, 3 May 2024 11:02:23 -0300 Subject: [PATCH 2/2] bump version --- Sabbath School.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sabbath School.xcodeproj/project.pbxproj b/Sabbath School.xcodeproj/project.pbxproj index 9ab23590..6ae8229e 100644 --- a/Sabbath School.xcodeproj/project.pbxproj +++ b/Sabbath School.xcodeproj/project.pbxproj @@ -2959,7 +2959,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 2; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = ""; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = XVGX5G4YQ9; @@ -3101,7 +3101,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 2; DEVELOPMENT_TEAM = ""; "DEVELOPMENT_TEAM[sdk=iphoneos*]" = XVGX5G4YQ9; ENABLE_BITCODE = NO;