From b46f3f6bf7388b23707b9996b5ec316073d86d20 Mon Sep 17 00:00:00 2001 From: marionbarker Date: Tue, 9 Apr 2024 22:18:15 -0700 Subject: [PATCH 1/4] enable use of environment appName --- G7SensorKit.xcodeproj/project.pbxproj | 4 ++++ G7SensorKitUI/Extensions/Bundle.swift | 15 +++++++++++++++ G7SensorKitUI/G7CGMManager/G7UICoordinator.swift | 1 + G7SensorKitUI/Views/G7StartupView.swift | 4 +++- 4 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 G7SensorKitUI/Extensions/Bundle.swift diff --git a/G7SensorKit.xcodeproj/project.pbxproj b/G7SensorKit.xcodeproj/project.pbxproj index c6c8c6a..ba30721 100644 --- a/G7SensorKit.xcodeproj/project.pbxproj +++ b/G7SensorKit.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + B60BB2E42BC649DA00D2BB39 /* Bundle.swift in Sources */ = {isa = PBXBuildFile; fileRef = B60BB2E32BC649DA00D2BB39 /* Bundle.swift */; }; C109F14A291ECCE2008EA5B6 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C109F149291ECCE2008EA5B6 /* Assets.xcassets */; }; C109F14C291ED66F008EA5B6 /* G7GlucoseMessageTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C109F14B291ED66F008EA5B6 /* G7GlucoseMessageTests.swift */; }; C139829829295D7D0047DB5F /* HKUnit.swift in Sources */ = {isa = PBXBuildFile; fileRef = C17F514A291EB6F000555EB5 /* HKUnit.swift */; }; @@ -106,6 +107,7 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + B60BB2E32BC649DA00D2BB39 /* Bundle.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Bundle.swift; path = G7SensorKitUI/Extensions/Bundle.swift; sourceTree = SOURCE_ROOT; }; C1086B0E29C9169100D46E65 /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Localizable.strings; sourceTree = ""; }; C1086B0F29C9169100D46E65 /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Localizable.strings; sourceTree = ""; }; C109F149291ECCE2008EA5B6 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; @@ -318,6 +320,7 @@ children = ( C17F5103291EAC9D00555EB5 /* G7CGMManager+UI.swift */, C17F5104291EAC9D00555EB5 /* G7UICoordinator.swift */, + B60BB2E32BC649DA00D2BB39 /* Bundle.swift */, ); path = G7CGMManager; sourceTree = ""; @@ -636,6 +639,7 @@ buildActionMask = 2147483647; files = ( C17F5108291EAC9D00555EB5 /* G7SettingsView.swift in Sources */, + B60BB2E42BC649DA00D2BB39 /* Bundle.swift in Sources */, C17F5157291EBD9900555EB5 /* TimeInterval.swift in Sources */, C19C9F4E29C91C4C00A6D3D0 /* LocalizedString.swift in Sources */, C17F5156291EBD8600555EB5 /* Image.swift in Sources */, diff --git a/G7SensorKitUI/Extensions/Bundle.swift b/G7SensorKitUI/Extensions/Bundle.swift new file mode 100644 index 0000000..0c37cd6 --- /dev/null +++ b/G7SensorKitUI/Extensions/Bundle.swift @@ -0,0 +1,15 @@ +// +// Bundle.swift +// LoopOnboardingKitUI +// +// Created by Darin Krauss on 1/23/21. +// Copyright © 2021 LoopKit Authors. All rights reserved. +// + +import Foundation + +extension Bundle { + var bundleDisplayName: String { + return object(forInfoDictionaryKey: "CFBundleDisplayName") as! String + } +} diff --git a/G7SensorKitUI/G7CGMManager/G7UICoordinator.swift b/G7SensorKitUI/G7CGMManager/G7UICoordinator.swift index 14d4359..0906587 100644 --- a/G7SensorKitUI/G7CGMManager/G7UICoordinator.swift +++ b/G7SensorKitUI/G7CGMManager/G7UICoordinator.swift @@ -54,6 +54,7 @@ class G7UICoordinator: UINavigationController, CGMManagerOnboarding, CompletionN } } ) + .environment(\.appName, Bundle.main.bundleDisplayName) let hostingController = DismissibleHostingController(content: rootView, colorPalette: colorPalette) hostingController.navigationItem.largeTitleDisplayMode = .never hostingController.title = nil diff --git a/G7SensorKitUI/Views/G7StartupView.swift b/G7SensorKitUI/Views/G7StartupView.swift index edc999c..72d2abb 100644 --- a/G7SensorKitUI/Views/G7StartupView.swift +++ b/G7SensorKitUI/Views/G7StartupView.swift @@ -13,6 +13,8 @@ struct G7StartupView: View { var didContinue: (() -> Void)? var didCancel: (() -> Void)? + @Environment(\.appName) private var appName + var body: some View { VStack(alignment: .center, spacing: 20) { Spacer() @@ -26,7 +28,7 @@ struct G7StartupView: View { .frame(height: 120) .padding(.horizontal) }.frame(maxWidth: .infinity) - Text(LocalizedString("Loop can read G7 CGM data, but you must still use the Dexcom G7 App for pairing, calibration, and other sensor management.", comment: "Descriptive text on G7StartupView")) + Text(LocalizedString("\(self.appName) can read G7 CGM data, but you must still use the Dexcom G7 App for pairing, calibration, and other sensor management.", comment: "Instructions for G7")) .fixedSize(horizontal: false, vertical: true) .foregroundColor(.secondary) Spacer() From 10ab9fccbdcf623d0464409353deefde5e833d9a Mon Sep 17 00:00:00 2001 From: marionbarker Date: Tue, 9 Apr 2024 22:29:11 -0700 Subject: [PATCH 2/4] restore comment to original --- G7SensorKitUI/Views/G7StartupView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/G7SensorKitUI/Views/G7StartupView.swift b/G7SensorKitUI/Views/G7StartupView.swift index 72d2abb..a7b91c7 100644 --- a/G7SensorKitUI/Views/G7StartupView.swift +++ b/G7SensorKitUI/Views/G7StartupView.swift @@ -28,7 +28,7 @@ struct G7StartupView: View { .frame(height: 120) .padding(.horizontal) }.frame(maxWidth: .infinity) - Text(LocalizedString("\(self.appName) can read G7 CGM data, but you must still use the Dexcom G7 App for pairing, calibration, and other sensor management.", comment: "Instructions for G7")) + Text(LocalizedString("\(self.appName) can read G7 CGM data, but you must still use the Dexcom G7 App for pairing, calibration, and other sensor management.", comment: "Descriptive text on G7StartupView")) .fixedSize(horizontal: false, vertical: true) .foregroundColor(.secondary) Spacer() From 1ab82de1bcceb4e4bbb33d7945c5d22eeca2a12d Mon Sep 17 00:00:00 2001 From: marionbarker Date: Wed, 10 Apr 2024 05:30:01 -0700 Subject: [PATCH 3/4] modify text with appName so translation string remains constant --- G7SensorKitUI/Views/G7StartupView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/G7SensorKitUI/Views/G7StartupView.swift b/G7SensorKitUI/Views/G7StartupView.swift index a7b91c7..ccd84a3 100644 --- a/G7SensorKitUI/Views/G7StartupView.swift +++ b/G7SensorKitUI/Views/G7StartupView.swift @@ -28,7 +28,7 @@ struct G7StartupView: View { .frame(height: 120) .padding(.horizontal) }.frame(maxWidth: .infinity) - Text(LocalizedString("\(self.appName) can read G7 CGM data, but you must still use the Dexcom G7 App for pairing, calibration, and other sensor management.", comment: "Descriptive text on G7StartupView")) + Text(String(format: LocalizedString("%1$@ can read G7 CGM data, but you must still use the Dexcom G7 App for pairing, calibration, and other sensor management.", comment: "Descriptive text on G7StartupView (1: appName)"), self.appName)) .fixedSize(horizontal: false, vertical: true) .foregroundColor(.secondary) Spacer() From c3c50b8466d02d5d72b843955c75250874d60435 Mon Sep 17 00:00:00 2001 From: marionbarker Date: Wed, 10 Apr 2024 05:42:08 -0700 Subject: [PATCH 4/4] update Xcode placement of Bundle.swift, fix typo in header --- G7SensorKit.xcodeproj/project.pbxproj | 2 +- G7SensorKitUI/Extensions/Bundle.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/G7SensorKit.xcodeproj/project.pbxproj b/G7SensorKit.xcodeproj/project.pbxproj index ba30721..238d8fc 100644 --- a/G7SensorKit.xcodeproj/project.pbxproj +++ b/G7SensorKit.xcodeproj/project.pbxproj @@ -320,7 +320,6 @@ children = ( C17F5103291EAC9D00555EB5 /* G7CGMManager+UI.swift */, C17F5104291EAC9D00555EB5 /* G7UICoordinator.swift */, - B60BB2E32BC649DA00D2BB39 /* Bundle.swift */, ); path = G7CGMManager; sourceTree = ""; @@ -369,6 +368,7 @@ C17F5154291EBD7100555EB5 /* Extensions */ = { isa = PBXGroup; children = ( + B60BB2E32BC649DA00D2BB39 /* Bundle.swift */, C17F5155291EBD8600555EB5 /* Image.swift */, ); path = Extensions; diff --git a/G7SensorKitUI/Extensions/Bundle.swift b/G7SensorKitUI/Extensions/Bundle.swift index 0c37cd6..73a1f57 100644 --- a/G7SensorKitUI/Extensions/Bundle.swift +++ b/G7SensorKitUI/Extensions/Bundle.swift @@ -1,6 +1,6 @@ // // Bundle.swift -// LoopOnboardingKitUI +// G7SensorKit // // Created by Darin Krauss on 1/23/21. // Copyright © 2021 LoopKit Authors. All rights reserved.