Closed33

M-1 Timerをつくる

蔀

概要

  • 賞レース出てる芸人はn分ネタをやる
  • 時計チラチラ見ることはできないから、1分ごとにApple Watchが震えると良さそう
    • インターバルは任意で変えられるとなおよし
  • 賞レースだけじゃなくて、プレゼンとかでも使える?
蔀

英語日本語対応しようと思ったら、String Catalogstというものができてたらしい

https://zenn.dev/rockname/articles/dc9d862bbdac4b

蔀

key / value同じにするの、良くないっぽいけど、今回はアプリめちゃくちゃ小さいからいいか
Startをkeyにしてカタログに登録したら、

Text("Start")

これがもうローカライズ文字列として処理されるようになった。
便利な反面、ダブルクオーテーションは単純文字列として扱って欲しいような気持ちもある。。。

蔀

1回戦は「2分」/2回戦・3回戦は「3分」/準々決勝・準決勝・敗者復活戦・決勝は「4分」

https://www.m-1gp.com/archive/2022/entry/

蔀

やっぱデフォルト、分単位の設定がいいかな。
もっと細かく秒指定できるオプションをつける感じで

蔀

push/popしたくなった
画面遷移にpath使うのが良さそう

https://sarunw.com/posts/how-to-pop-view-from-navigation-stack-in-swiftui/

蔀

便利だと思ったら、トップでしか使えないらしい……あんま意味ないじゃん

Only root-level navigation destinations are effective for a navigation stack with a homogeneous path.
蔀

あ、違うな。
トップで[Path]を保持して、Bindingで渡していけってことかな?

蔀

Timerのキャンセル、サボろうかと思ったら、キャンセルしないとViewが消えても動き続けるっぽい

蔀

Pickerの謎のバグに出くわした
1〜60までの値を生成したら1に戻される

import SwiftUI

struct SettingView: View {
    @AppStorage("Timelimit") var timelimit: TimeInterval = 120
    @AppStorage("VibrationInterval") var vibrationInterval: TimeInterval = 60
    @State var selectedTimelimit: Timelimit = .two
    @State var selectedVibrationInterval: TimeInterval = 60
    
    var body: some View {
        VStack {
            HStack() {
                Text("Time\nlimit")
                Picker("", selection: $selectedTimelimit) {
                    ForEach(Timelimit.allCases) {
                        Text($0.title)
                    }
                }
                .onChange(of: selectedTimelimit) {
                    
                }
                Text("min")
            }
            HStack() {
                Text("Interval")
                Picker("", selection: $selectedVibrationInterval) {
                    ForEach(1..<101) {
                        Text(String($0))
                    }
                }
                .onChange(of: vibrationInterval) {
                    // …
                }
                Text("sec")
            }
        }
        .onAppear {
            selectedTimelimit = Timelimit(interval: timelimit)
            selectedVibrationInterval = vibrationInterval
        }
    }
}

蔀

このエラーが出てるけど、関係あるのかないのか不明

ScrollView contentOffset binding has been read; this will cause grossly inefficient view performance as the ScrollView's content will be updated whenever its contentOffset changes. Read the contentOffset binding in a view that is not parented between the creator of the binding and the ScrollView to avoid this.
蔀

もしかしたらシミュレーターだけの問題なのかな?

蔀

あーわかった。渡してる値がDoubleだからか……

蔀

@AppStorage の値も Binding可能らしい。
PickerView、同じViewを使いまわせた

蔀

ちょうどいい目的がない
なんとなくPhysical therapyにするか

Self care
Guide users through relatively brief activities. These activities focus on the user’s emotional well-being or health, such as brushing their teeth.

Mindfulness
Help users start and end silent meditation sessions. For walking meditation, consider using HKWorkoutSession instead. Similarly, if your app plays audio during the entire meditation session, there’s no reason to use a WKExtendedRuntimeSession. The background audio mode provides additional runtime as long as the audio plays. For more information, see Playing Background Audio.

Physical therapy
Guide users through stretching, strengthening, or range-of-motion exercises. If the physical therapy activity is strenuous—for example, riding an exercise bike—consider using an HKWorkoutSession instead.

Smart alarm
Schedule a window of time to monitor the user’s heart rate and motion. The app uses this information to determine the optimal time to play an alarm, usually to wake the user from sleep.
蔀

シミュレーターでも音でHapticは確認できた
バックグラウンドでも動いてそうだね

このスクラップは4ヶ月前にクローズされました