Skip to content

Commit 2748caa

Browse files
Merge pull request #160 from Adventech/feature/fixes-widgets-iOS17
Fixes widgets iOS 17
2 parents 8764a1e + b9f54ea commit 2748caa

File tree

8 files changed

+64
-4
lines changed

8 files changed

+64
-4
lines changed

Sabbath School.xcodeproj/project.pbxproj

+18-2
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@
8686
4E6B1A6C2AACDA42006B9283 /* NotificationCenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EE8B6F4284D1FAA003C1A46 /* NotificationCenter.swift */; };
8787
4E7B09892814CA3D00687C33 /* Encodable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E7B09882814CA3D00687C33 /* Encodable.swift */; };
8888
4E7B098C2814CA8A00687C33 /* Comparable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E7B098B2814CA8A00687C33 /* Comparable.swift */; };
89+
4E7E4F3F2B79715D00920230 /* ViewExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E7E4F3E2B79715D00920230 /* ViewExtensions.swift */; };
90+
4E7E4F412B7971A900920230 /* WidgetConfigurationExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E7E4F402B7971A900920230 /* WidgetConfigurationExtensions.swift */; };
8991
4E80B4232AC0A2DA002B6FBF /* SabbathSchoolTVApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E80B4222AC0A2DA002B6FBF /* SabbathSchoolTVApp.swift */; };
9092
4E80B4252AC0A2DA002B6FBF /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E80B4242AC0A2DA002B6FBF /* ContentView.swift */; };
9193
4E80B4272AC0A2DA002B6FBF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4E80B4262AC0A2DA002B6FBF /* Assets.xcassets */; };
@@ -393,6 +395,8 @@
393395
4E6409F427C5593A00A43D89 /* ScrollView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScrollView.swift; sourceTree = "<group>"; };
394396
4E7B09882814CA3D00687C33 /* Encodable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Encodable.swift; sourceTree = "<group>"; };
395397
4E7B098B2814CA8A00687C33 /* Comparable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Comparable.swift; sourceTree = "<group>"; };
398+
4E7E4F3E2B79715D00920230 /* ViewExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewExtensions.swift; sourceTree = "<group>"; };
399+
4E7E4F402B7971A900920230 /* WidgetConfigurationExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidgetConfigurationExtensions.swift; sourceTree = "<group>"; };
396400
4E80B4202AC0A2D9002B6FBF /* SabbathSchoolTV.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SabbathSchoolTV.app; sourceTree = BUILT_PRODUCTS_DIR; };
397401
4E80B4222AC0A2DA002B6FBF /* SabbathSchoolTVApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SabbathSchoolTVApp.swift; sourceTree = "<group>"; };
398402
4E80B4242AC0A2DA002B6FBF /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
@@ -867,6 +871,15 @@
867871
path = Protocols;
868872
sourceTree = "<group>";
869873
};
874+
4E7E4F3D2B796FB900920230 /* Extensions */ = {
875+
isa = PBXGroup;
876+
children = (
877+
4E7E4F3E2B79715D00920230 /* ViewExtensions.swift */,
878+
4E7E4F402B7971A900920230 /* WidgetConfigurationExtensions.swift */,
879+
);
880+
path = Extensions;
881+
sourceTree = "<group>";
882+
};
870883
4E80B4212AC0A2DA002B6FBF /* SabbathSchoolTV */ = {
871884
isa = PBXGroup;
872885
children = (
@@ -1621,6 +1634,7 @@
16211634
FE1E35012673C5DF00DAC2D6 /* Widget */ = {
16221635
isa = PBXGroup;
16231636
children = (
1637+
4E7E4F3D2B796FB900920230 /* Extensions */,
16241638
FED6B2D22680262E007093CE /* LessonInfoWidget */,
16251639
FE611A642674F9D2003CDDB5 /* TodayWidget */,
16261640
FE44266F26751C160038A863 /* Resources */,
@@ -2393,6 +2407,7 @@
23932407
FED6B3032680E0D9007093CE /* String.swift in Sources */,
23942408
FE611AAB267500F5003CDDB5 /* Day.swift in Sources */,
23952409
FEC92205267FB09100422F3D /* Color.swift in Sources */,
2410+
4E7E4F3F2B79715D00920230 /* ViewExtensions.swift in Sources */,
23962411
FE3FFA5426B11F4E0037539F /* QuarterlyGroup.swift in Sources */,
23972412
FE611AAD267500F5003CDDB5 /* Comment.swift in Sources */,
23982413
FE611AAC267500F5003CDDB5 /* LessonInfo.swift in Sources */,
@@ -2424,6 +2439,7 @@
24242439
FED6B2EB268026D0007093CE /* LessonInfoWidget.swift in Sources */,
24252440
FED6B2E6268026AE007093CE /* LessonInfoWidgetProvider.swift in Sources */,
24262441
FED6B3122680E6F7007093CE /* WidgetInteractor.swift in Sources */,
2442+
4E7E4F412B7971A900920230 /* WidgetConfigurationExtensions.swift in Sources */,
24272443
2F95D39F26C0B2E8008E6666 /* Audio.swift in Sources */,
24282444
FEC9219B267E452800422F3D /* Helper.swift in Sources */,
24292445
FED6B35826818BEA007093CE /* FeaturedTodayWidget.swift in Sources */,
@@ -2943,7 +2959,7 @@
29432959
CODE_SIGN_IDENTITY = "Apple Development";
29442960
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
29452961
CODE_SIGN_STYLE = Manual;
2946-
CURRENT_PROJECT_VERSION = 1;
2962+
CURRENT_PROJECT_VERSION = 2;
29472963
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
29482964
DEVELOPMENT_TEAM = "";
29492965
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = XVGX5G4YQ9;
@@ -3085,7 +3101,7 @@
30853101
CODE_SIGN_IDENTITY = "Apple Development";
30863102
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
30873103
CODE_SIGN_STYLE = Manual;
3088-
CURRENT_PROJECT_VERSION = 1;
3104+
CURRENT_PROJECT_VERSION = 2;
30893105
DEVELOPMENT_TEAM = "";
30903106
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = XVGX5G4YQ9;
30913107
ENABLE_BITCODE = NO;
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//
2+
// ViewExtensions.swift
3+
// WidgetExtension
4+
//
5+
// Created by Emerson Carpes on 11/02/24.
6+
// Copyright © 2024 Adventech. All rights reserved.
7+
//
8+
9+
import SwiftUI
10+
11+
extension View {
12+
func widgetBackground(_ backgroundView: some View) -> some View {
13+
if #available(iOSApplicationExtension 17.0, *) {
14+
return containerBackground(for: .widget) {
15+
backgroundView
16+
}
17+
} else {
18+
return background(backgroundView)
19+
}
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//
2+
// WidgetConfigurationExtensions.swift
3+
// WidgetExtension
4+
//
5+
// Created by Emerson Carpes on 11/02/24.
6+
// Copyright © 2024 Adventech. All rights reserved.
7+
//
8+
9+
import SwiftUI
10+
11+
extension WidgetConfiguration {
12+
func contentMarginsDisabledIfAvailable() -> some WidgetConfiguration {
13+
if #available(iOSApplicationExtension 17.0, *) {
14+
return self.contentMarginsDisabled()
15+
}
16+
else {
17+
return self
18+
}
19+
}
20+
}

Widget/LessonInfoWidget/LessonInfoWidget.swift

+1
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,6 @@ struct LessonInfoWidget: Widget {
3535
.configurationDisplayName("This week's lesson".localized())
3636
.description("Preview and access Sabbath School lesson for this week".localized())
3737
.supportedFamilies([.systemLarge])
38+
.contentMarginsDisabledIfAvailable()
3839
}
3940
}

Widget/TodayWidget/FeaturedTodayWidget.swift

+1
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,6 @@ struct FeaturedTodayWidget: Widget {
3535
.configurationDisplayName("Today's lesson".localized())
3636
.description("Get quick access the Sabbath School lesson for today, featuring the background image".localized())
3737
.supportedFamilies([.systemSmall, .systemMedium])
38+
.contentMarginsDisabledIfAvailable()
3839
}
3940
}

Widget/TodayWidget/FeaturedTodayWidgetView.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ struct FeaturedTodayWidgetView : View {
6969
.padding(.bottom, 5)
7070
.padding(.leading, 20)
7171
.padding(.trailing, 20)
72-
.background(Color.init(UIColor.baseBlue))
72+
.widgetBackground(Color.init(UIColor.baseBlue))
7373
.foregroundColor(.white)
7474
.cornerRadius(11)
7575
.font(.system(size: 9, weight: .bold))

Widget/TodayWidget/TodayWidget.swift

+1
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,6 @@ struct TodayWidget: Widget {
3535
.configurationDisplayName("Today's lesson".localized())
3636
.description("Get quick access the Sabbath School lesson for today".localized())
3737
.supportedFamilies([.systemSmall, .systemMedium])
38+
.contentMarginsDisabledIfAvailable()
3839
}
3940
}

Widget/TodayWidget/TodayWidgetView.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ struct TodayWidgetView : View {
6262
.padding(.bottom, 5)
6363
.padding(.leading, 20)
6464
.padding(.trailing, 20)
65-
.background(Color.init(UIColor.baseBlue))
65+
.widgetBackground(Color.init(UIColor.baseBlue))
6666
.foregroundColor(.white)
6767
.cornerRadius(11)
6868
.font(.system(size: 9, weight: .bold))

0 commit comments

Comments
 (0)