Skip to content

Commit 5301e43

Browse files
committed
update to match version merged into dev
1 parent db5be41 commit 5301e43

File tree

1 file changed

+50
-47
lines changed

1 file changed

+50
-47
lines changed

testflight_expiration_warning/main_tf_alert.patch

Lines changed: 50 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
diff --git a/Loop/Loop/Managers/ProfileExpirationAlerter.swift b/Loop/Managers/ProfileExpirationAlerter.swift
2-
index a28d4527..068e6327 100644
1+
Submodule Loop contains modified content
2+
diff --git a/Loop/Loop/Managers/ProfileExpirationAlerter.swift b/Loop/Loop/Managers/ProfileExpirationAlerter.swift
3+
index a28d4527..62f458fb 100644
34
--- a/Loop/Loop/Managers/ProfileExpirationAlerter.swift
45
+++ b/Loop/Loop/Managers/ProfileExpirationAlerter.swift
56
@@ -19,13 +19,19 @@ class ProfileExpirationAlerter {
@@ -88,7 +89,7 @@ index a28d4527..068e6327 100644
8889
let relativeTimeRemaining: String = readableRelativeTime ?? NSLocalizedString("Unknown time", comment: "Unknown amount of time in settings' profile expiration section")
8990
let verboseMessage = createVerboseAlertMessage(timeUntilExpirationStr: relativeTimeRemaining)
9091
let conciseMessage = relativeTimeRemaining + NSLocalizedString(" remaining", comment: "remaining time in setting's profile expiration section")
91-
@@ -81,6 +104,50 @@ class ProfileExpirationAlerter {
92+
@@ -81,6 +104,56 @@ class ProfileExpirationAlerter {
9293
formatter.unitsStyle = .full
9394
formatter.zeroFormattingBehavior = .dropLeading
9495
formatter.maximumUnitCount = maxUnitCount
@@ -111,6 +112,12 @@ index a28d4527..068e6327 100644
111112
+ }
112113
+
113114
+ static func isTestFlightBuild() -> Bool {
115+
+ // If the target environment is a simulator, then
116+
+ // this is not a TestFlight distribution. Return false.
117+
+ #if targetEnvironment(simulator)
118+
+ return false
119+
+ #endif
120+
+
114121
+ // If an "embedded.mobileprovision" is present in the main bundle, then
115122
+ // this is an Xcode, Ad-Hoc, or Enterprise distribution. Return false.
116123
+ if Bundle.main.url(forResource: "embedded", withExtension: "mobileprovision") != nil {
@@ -141,10 +148,10 @@ index a28d4527..068e6327 100644
141148
}
142149
}
143150
diff --git a/Loop/Loop/Views/SettingsView.swift b/Loop/Loop/Views/SettingsView.swift
144-
index 90859273..e41ebfa2 100644
151+
index 90859273..4021e5d4 100644
145152
--- a/Loop/Loop/Views/SettingsView.swift
146153
+++ b/Loop/Loop/Views/SettingsView.swift
147-
@@ -343,25 +343,48 @@ extension SettingsView {
154+
@@ -343,23 +343,50 @@ extension SettingsView {
148155
DIY loop specific component to show users the amount of time remaining on their build before a rebuild is necessary.
149156
*/
150157
private func profileExpirationSection(profileExpiration:Date) -> some View {
@@ -158,54 +165,50 @@ index 90859273..e41ebfa2 100644
158165
- footer: Text(NSLocalizedString("Profile expires ", comment: "Time that profile expires") + readableExpirationTime)) {
159166
- if(nearExpiration) {
160167
- Text(profileExpirationMsg).foregroundColor(.red)
161-
- } else {
162-
- HStack {
163-
- Text("Profile Expiration", comment: "Settings App Profile expiration view")
164-
- Spacer()
165-
- Text(profileExpirationMsg).foregroundColor(Color.secondary)
166168
+ let nearExpiration : Bool = ProfileExpirationAlerter.isNearExpiration(expirationDate: expirationDate)
167169
+ let profileExpirationMsg = ProfileExpirationAlerter.createProfileExpirationSettingsMessage(expirationDate: expirationDate)
168170
+ let readableExpirationTime = Self.dateFormatter.string(from: expirationDate)
169171
+
170172
+ if isTestFlight {
171-
+ return Section(header: SectionHeader(label: NSLocalizedString("TestFlight", comment: "Settings app TestFlight section")),
172-
+ footer: Text(NSLocalizedString("TestFlight expires ", comment: "Time that build expires") + readableExpirationTime)) {
173-
+ if(nearExpiration) {
174-
+ Text(profileExpirationMsg).foregroundColor(.red)
175-
+ } else {
176-
+ HStack {
177-
+ Text("TestFlight Expiration", comment: "Settings TestFlight expiration view")
178-
+ Spacer()
179-
+ Text(profileExpirationMsg).foregroundColor(Color.secondary)
180-
+ }
181-
+ }
182-
+ Button(action: {
183-
+ UIApplication.shared.open(URL(string: "https://loopkit.github.io/loopdocs/gh-actions/gh-update/")!)
184-
+ }) {
185-
+ Text(NSLocalizedString("How to update (LoopDocs)", comment: "The title text for how to update"))
173+
+ return createAppExpirationSection(
174+
+ headerLabel: NSLocalizedString("TestFlight", comment: "Settings app TestFlight section"),
175+
+ footerLabel: NSLocalizedString("TestFlight expires ", comment: "Time that build expires") + readableExpirationTime,
176+
+ expirationLabel: NSLocalizedString("TestFlight Expiration", comment: "Settings TestFlight expiration view"),
177+
+ updateURL: "https://loopkit.github.io/loopdocs/gh-actions/gh-update/",
178+
+ nearExpiration: nearExpiration,
179+
+ expirationMessage: profileExpirationMsg
180+
+ )
181+
+ } else {
182+
+ return createAppExpirationSection(
183+
+ headerLabel: NSLocalizedString("App Profile", comment: "Settings app profile section"),
184+
+ footerLabel: NSLocalizedString("Profile expires ", comment: "Time that profile expires") + readableExpirationTime,
185+
+ expirationLabel: NSLocalizedString("Profile Expiration", comment: "Settings App Profile expiration view"),
186+
+ updateURL: "https://loopkit.github.io/loopdocs/build/updating/",
187+
+ nearExpiration: nearExpiration,
188+
+ expirationMessage: profileExpirationMsg
189+
+ )
190+
+ }
191+
+ }
192+
+
193+
+ private func createAppExpirationSection(headerLabel: String, footerLabel: String, expirationLabel: String, updateURL: String, nearExpiration: Bool, expirationMessage: String) -> some View {
194+
+ return Section(
195+
+ header: SectionHeader(label: headerLabel),
196+
+ footer: Text(footerLabel)
197+
+ ) {
198+
+ if nearExpiration {
199+
+ Text(expirationMessage).foregroundColor(.red)
200+
} else {
201+
HStack {
202+
- Text("Profile Expiration", comment: "Settings App Profile expiration view")
203+
+ Text(expirationLabel)
204+
Spacer()
205+
- Text(profileExpirationMsg).foregroundColor(Color.secondary)
206+
+ Text(expirationMessage).foregroundColor(Color.secondary)
186207
}
187208
}
188-
- Button(action: {
209+
Button(action: {
189210
- UIApplication.shared.open(URL(string: "https://loopkit.github.io/loopdocs/build/updating/")!)
190-
- }) {
191-
- Text(NSLocalizedString("How to update (LoopDocs)", comment: "The title text for how to update"))
192-
+ } else {
193-
+ return Section(header: SectionHeader(label: NSLocalizedString("App Profile", comment: "Settings app profile section")),
194-
+ footer: Text(NSLocalizedString("Profile expires ", comment: "Time that profile expires") + readableExpirationTime)) {
195-
+ if(nearExpiration) {
196-
+ Text(profileExpirationMsg).foregroundColor(.red)
197-
+ } else {
198-
+ HStack {
199-
+ Text("Profile Expiration", comment: "Settings App Profile expiration view")
200-
+ Spacer()
201-
+ Text(profileExpirationMsg).foregroundColor(Color.secondary)
202-
+ }
203-
+ }
204-
+ Button(action: {
205-
+ UIApplication.shared.open(URL(string: "https://loopkit.github.io/loopdocs/build/updating/")!)
206-
+ }) {
207-
+ Text(NSLocalizedString("How to update (LoopDocs)", comment: "The title text for how to update"))
208-
+ }
211+
+ UIApplication.shared.open(URL(string: updateURL)!)
212+
}) {
213+
Text(NSLocalizedString("How to update (LoopDocs)", comment: "The title text for how to update"))
209214
}
210-
}
211-
}

0 commit comments

Comments
 (0)