Skip to content

Commit 0d2ac9c

Browse files
authored
Merge pull request #30 from olearytd/issue-15
add language support to setup screen
2 parents 2040b5b + 31473bb commit 0d2ac9c

File tree

10 files changed

+488
-26
lines changed

10 files changed

+488
-26
lines changed

NightreignTimer.xcodeproj/project.pbxproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@
419419
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
420420
CODE_SIGN_ENTITLEMENTS = NightreignTimer/NightreignTimer.entitlements;
421421
CODE_SIGN_STYLE = Automatic;
422-
CURRENT_PROJECT_VERSION = 2;
422+
CURRENT_PROJECT_VERSION = 1;
423423
DEVELOPMENT_TEAM = LCM5FMVWQD;
424424
ENABLE_PREVIEWS = YES;
425425
GENERATE_INFOPLIST_FILE = YES;
@@ -435,7 +435,7 @@
435435
"$(inherited)",
436436
"@executable_path/Frameworks",
437437
);
438-
MARKETING_VERSION = 1.3.2;
438+
MARKETING_VERSION = 1.4.0;
439439
PRODUCT_BUNDLE_IDENTIFIER = toleary.NightreignTimer;
440440
PRODUCT_NAME = "$(TARGET_NAME)";
441441
SWIFT_EMIT_LOC_STRINGS = YES;
@@ -451,7 +451,7 @@
451451
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
452452
CODE_SIGN_ENTITLEMENTS = NightreignTimer/NightreignTimer.entitlements;
453453
CODE_SIGN_STYLE = Automatic;
454-
CURRENT_PROJECT_VERSION = 2;
454+
CURRENT_PROJECT_VERSION = 1;
455455
DEVELOPMENT_TEAM = LCM5FMVWQD;
456456
ENABLE_PREVIEWS = YES;
457457
GENERATE_INFOPLIST_FILE = YES;
@@ -467,7 +467,7 @@
467467
"$(inherited)",
468468
"@executable_path/Frameworks",
469469
);
470-
MARKETING_VERSION = 1.3.2;
470+
MARKETING_VERSION = 1.4.0;
471471
PRODUCT_BUNDLE_IDENTIFIER = toleary.NightreignTimer;
472472
PRODUCT_NAME = "$(TARGET_NAME)";
473473
SWIFT_EMIT_LOC_STRINGS = YES;
@@ -691,7 +691,7 @@
691691
"@executable_path/Frameworks",
692692
"@executable_path/../../Frameworks",
693693
);
694-
MARKETING_VERSION = 1.3.2;
694+
MARKETING_VERSION = 1.4.0;
695695
PRODUCT_BUNDLE_IDENTIFIER = toleary.NightreignTimer.NightreignWidget;
696696
PRODUCT_NAME = "$(TARGET_NAME)";
697697
SKIP_INSTALL = YES;
@@ -719,7 +719,7 @@
719719
"@executable_path/Frameworks",
720720
"@executable_path/../../Frameworks",
721721
);
722-
MARKETING_VERSION = 1.3.2;
722+
MARKETING_VERSION = 1.4.0;
723723
PRODUCT_BUNDLE_IDENTIFIER = toleary.NightreignTimer.NightreignWidget;
724724
PRODUCT_NAME = "$(TARGET_NAME)";
725725
SKIP_INSTALL = YES;

NightreignTimer/ContentView.swift

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,29 @@ struct ContentView: View {
183183
}
184184

185185
Button(NSLocalizedString("reset", comment: "Reset button")) {
186+
// Reset tooltip text as before
186187
tooltipText = NSLocalizedString("start_timer_tooltip_day_1", comment: "Tooltip for starting timer on Day 1")
187-
stopTimer()
188-
day = 1
189-
currentPhaseIndex = 0
190-
timeRemaining = dayPhases[0].duration
191-
isRunning = false
192-
wasPaused = false
193-
showPhaseWarning = false
188+
// End the live activity if running (same as in restartGame)
189+
Task {
190+
await liveActivity?.end(
191+
ActivityContent(
192+
state: NightreignWidgetAttributes.ContentState(
193+
timeRemaining: 0,
194+
phaseLabel: NSLocalizedString("reset_phase_label", comment: "Reset phase label")
195+
),
196+
staleDate: nil
197+
),
198+
dismissalPolicy: .immediate
199+
)
200+
}
201+
// Navigate back to SetupView by replacing the root view
202+
if let scene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
203+
let window = scene.windows.first {
204+
window.rootViewController = UIHostingController(
205+
rootView: SetupView().environment(\.managedObjectContext, viewContext)
206+
)
207+
window.makeKeyAndVisible()
208+
}
194209
}
195210
.padding(.top)
196211
.controlSize(.large)
@@ -467,15 +482,7 @@ struct ContentView: View {
467482
}
468483

469484
func restartGame() {
470-
stopTimer()
471-
day = 1
472-
currentPhaseIndex = 0
473-
timeRemaining = dayPhases[0].duration
474-
isRunning = false
475-
wasPaused = false
476-
showPhaseWarning = false
477-
hasAnswered = false
478-
tooltipText = NSLocalizedString("start_timer_tooltip_day_1", comment: "Tooltip for starting timer on Day 1")
485+
// End the live activity if running
479486
Task {
480487
await liveActivity?.end(
481488
ActivityContent(
@@ -487,7 +494,14 @@ struct ContentView: View {
487494
),
488495
dismissalPolicy: .immediate
489496
)
490-
liveActivity = nil
497+
}
498+
// Navigate back to SetupView by replacing the root view
499+
if let scene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
500+
let window = scene.windows.first {
501+
window.rootViewController = UIHostingController(
502+
rootView: SetupView().environment(\.managedObjectContext, viewContext)
503+
)
504+
window.makeKeyAndVisible()
491505
}
492506
}
493507

NightreignTimer/NightreignTimer.xcdatamodeld/NightreignTimer.xcdatamodel/contents

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2-
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="23788.4" systemVersion="24F74" minimumToolsVersion="Automatic" sourceLanguage="Swift" usedWithSwiftData="YES" userDefinedModelVersionIdentifier="">
2+
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="23788.4" systemVersion="24G84" minimumToolsVersion="Automatic" sourceLanguage="Swift" usedWithSwiftData="YES" userDefinedModelVersionIdentifier="">
33
<entity name="GameStats" representedClassName="GameStats" syncable="YES" codeGenerationType="class">
4+
<attribute name="character" optional="YES" attributeType="String"/>
45
<attribute name="dateTime" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
6+
<attribute name="gameType" optional="YES" attributeType="String"/>
57
<attribute name="id" optional="YES" attributeType="UUID" usesScalarValueType="NO"/>
8+
<attribute name="nightLord" optional="YES" attributeType="String"/>
69
<attribute name="totalAttempts" optional="YES" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>
710
<attribute name="winCount" optional="YES" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>
811
</entity>

NightreignTimer/NightreignTimerApp.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ struct NightreignTimerApp: App {
1414

1515
var body: some Scene {
1616
WindowGroup {
17-
ContentView()
17+
SetupView()
1818
.environment(\.managedObjectContext,
1919
persistenceController.container.viewContext)
2020
}

0 commit comments

Comments
 (0)