Created
April 2, 2024 04:33
-
-
Save hesbryce/7322d0ef32b4573bb832a7fb999ac2d2 to your computer and use it in GitHub Desktop.
Stamina Bar set goal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// SetStaminaBarGoalView.swift | |
// Stamina Bar Watch App | |
// | |
// Created by Bryce Ellis on 6/12/23. | |
// | |
import Foundation | |
import SwiftUI | |
struct SetStaminaBarGoalView: View { | |
@State private var staminaPercentage = 100.0 | |
@State private var isEditing = false | |
var body: some View { | |
VStack { | |
Text("Set Stamina Goal") | |
Image("\(Int(staminaPercentage))") | |
.resizable() | |
.aspectRatio(contentMode: .fit) | |
.onTapGesture { | |
self.isEditing = true | |
} | |
// The label displaying the current stamina percentage | |
Text("\(Int(staminaPercentage))%") | |
.focusable(isEditing) | |
.digitalCrownRotation($staminaPercentage, from: 1, through: 100, by: 1, sensitivity: .low, isContinuous: false, isHapticFeedbackEnabled: true) | |
.onReceive(NotificationCenter.default.publisher(for: WKExtension.applicationDidBecomeActiveNotification)) { _ in | |
self.isEditing = false | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment