@@ -40,8 +40,7 @@ struct WatchFaceView: View {
4040 case 4 :
4141 InfineatWF ( geometry: . constant( geometry) )
4242 case 5 :
43- // Casio G7710
44- EmptyView ( )
43+ CasioWF ( geometry: . constant( geometry) )
4544 default :
4645 ProgressView ( )
4746 . frame ( width: geometry. size. width, height: geometry. size. height, alignment: . center)
@@ -476,6 +475,112 @@ struct TerminalWF: View {
476475 }
477476}
478477
478+ struct CasioWF : View {
479+ @ObservedObject var bleManagerVal = BLEManagerVal . shared
480+ @ObservedObject var bleManager = BLEManager . shared
481+ @Environment ( \. colorScheme) var colorScheme
482+ @Binding var geometry : GeometryProxy
483+
484+ let colorText : Color = Color ( red: 152 / 255.0 , green: 182 / 255.0 , blue: 154 / 255.0 )
485+
486+ var hour24 : Bool {
487+ switch bleManagerVal. timeFormat {
488+ case . H12:
489+ return false
490+ case . H24:
491+ return true
492+ default :
493+ return true
494+ }
495+ }
496+
497+ var body : some View {
498+ ZStack {
499+ Image ( " casio " )
500+ . scaleEffect ( 0.81 )
501+ CustomTextView ( text: String ( Int ( bleManager. batteryLevel) ) , font: . custom( " open_sans_light " , size: geometry. size. width * 0.09 ) , lineSpacing: 0 )
502+ . frame ( width: geometry. size. width, height: geometry. size. height, alignment: . topTrailing)
503+ . padding ( . trailing, 22 )
504+ CustomTextView (
505+ text: {
506+ let dateFormatter = DateFormatter ( )
507+ dateFormatter. dateFormat = " E "
508+
509+ let weekOfYear = Calendar . current. component ( . weekOfYear, from: Date ( ) )
510+
511+ return " WK \( weekOfYear) \n \( dateFormatter. string ( from: Date ( ) ) . uppercased ( ) ) "
512+ } ( ) ,
513+ font: . custom( " repetitionscrolling " , size: geometry. size. width * 0.16 ) ,
514+ lineSpacing: 0
515+ )
516+ . frame ( width: geometry. size. width / 1.04 , height: geometry. size. height / 1.2 , alignment: . topLeading)
517+ CustomTextView (
518+ text: {
519+ let calendar = Calendar . current
520+ let now = Date ( )
521+
522+ let startOfYear = calendar. startOfDay ( for: calendar. date ( from: DateComponents ( year: calendar. component ( . year, from: now) ) ) !)
523+ let endOfYear = calendar. startOfDay ( for: calendar. date ( byAdding: DateComponents ( year: 1 , day: - 1 ) , to: calendar. date ( from: DateComponents ( year: calendar. component ( . year, from: now) ) ) !) !)
524+
525+ let daysIn = calendar. dateComponents ( [ . day] , from: startOfYear, to: now) . day! + 1
526+ let daysLeft = calendar. dateComponents ( [ . day] , from: now, to: endOfYear) . day! + 1
527+
528+ return " \( daysIn) - \( daysLeft) "
529+ } ( ) ,
530+ font: . custom( " open_sans_light " , size: geometry. size. width * 0.13 ) ,
531+ lineSpacing: 0
532+ )
533+ . frame ( width: geometry. size. width / 1.04 , height: geometry. size. height / 1.3 , alignment: . topTrailing)
534+ CustomTextView (
535+ text: {
536+ let calendar = Calendar . current
537+ let now = Date ( )
538+
539+ let month = calendar. component ( . month, from: now)
540+ let day = calendar. component ( . day, from: now)
541+
542+ return " \( month) - \( day) "
543+ } ( ) ,
544+ font: . custom( " open_sans_light " , size: geometry. size. width * 0.13 ) ,
545+ lineSpacing: 0
546+ )
547+ . frame ( width: geometry. size. width / 1.08 , height: geometry. size. height / 2.25 , alignment: . topTrailing)
548+ if Calendar . current. component ( . hour, from: Date ( ) ) > 12 && !hour24 {
549+ CustomTextView ( text: " \( Calendar . current. component ( . hour, from: Date ( ) ) - 12 ) : \( String ( format: " %02d " , Calendar . current. component ( . minute, from: Date ( ) ) ) ) " , font: . custom( " 7-segment " , size: geometry. size. width * 0.36 ) , lineSpacing: 0 )
550+ . frame ( maxWidth: . infinity, maxHeight: . infinity, alignment: . trailing)
551+ . position ( x: geometry. size. width / 2.0 , y: geometry. size. height / 1.30 )
552+ } else {
553+ CustomTextView ( text: " \( String ( format: " %02d " , Calendar . current. component ( . hour, from: Date ( ) ) ) ) : \( String ( format: " %02d " , Calendar . current. component ( . minute, from: Date ( ) ) ) ) " , font: . custom( " 7-segment " , size: geometry. size. width * 0.36 ) , lineSpacing: 0 )
554+ . frame ( maxWidth: . infinity, maxHeight: . infinity, alignment: . trailing)
555+ . position ( x: geometry. size. width / 2.0 , y: geometry. size. height / 1.30 )
556+ }
557+ HStack ( spacing: 4 ) {
558+ Image ( systemName: " heart.fill " )
559+ . font ( . system( size: geometry. size. width * 0.08 ) )
560+ . foregroundColor ( bleManagerVal. heartBPM != 0 ? colorText : . gray)
561+ . opacity ( bleManagerVal. heartBPM != 0 ? 1.0 : 0.5 )
562+ if bleManagerVal. heartBPM != 0 {
563+ CustomTextView ( text: String ( Int ( bleManagerVal. heartBPM) ) , font: . custom( " open_sans_light " , size: geometry. size. width * 0.11 ) , lineSpacing: 0 )
564+ }
565+ }
566+ . frame ( width: geometry. size. width, height: geometry. size. height, alignment: . bottomLeading)
567+ . padding ( . leading, 10 )
568+ . padding ( . bottom, bleManagerVal. heartBPM != 0 ? 0 : - 4 )
569+ HStack ( spacing: 4 ) {
570+ Image ( systemName: " shoeprints.fill " )
571+ . rotationEffect ( Angle ( degrees: 90 ) )
572+ . font ( . system( size: geometry. size. width * 0.08 ) )
573+ CustomTextView ( text: " \( bleManagerVal. stepCount) " , font: . custom( " open_sans_light " , size: geometry. size. width * 0.11 ) , lineSpacing: 0 )
574+ }
575+ . frame ( width: geometry. size. width, height: geometry. size. height, alignment: . bottomTrailing)
576+ . padding ( . trailing, 10 )
577+ . padding ( . bottom, - 4 )
578+ }
579+ . foregroundColor ( colorText)
580+ . frame ( width: geometry. size. width, height: geometry. size. height, alignment: . center)
581+ }
582+ }
583+
479584struct CustomTextView : View {
480585 var text : String
481586 var font : Font
@@ -494,7 +599,7 @@ struct CustomTextView: View {
494599#Preview {
495600 NavigationView {
496601 GeometryReader { geometry in
497- WatchFaceView ( watchface: . constant( 4 ) )
602+ WatchFaceView ( watchface: . constant( 5 ) )
498603 . padding ( 22 )
499604 . frame ( width: geometry. size. width / 1.65 , height: geometry. size. width / 1.65 , alignment: . center)
500605 . clipped ( antialiased: true )
0 commit comments