HomeiOS DevelopmentHpw to keep away from dynamic island to takes the entire width...

Hpw to keep away from dynamic island to takes the entire width of the display screen


Hpw to keep away from dynamic island to takes the entire width of the display screen

enter image description here

I am utilizing timerInternal in my trailing view foe a dwell timer, when the timer is operating it would not respect the boundaries and it takes the entire display screen width however when it’s paused it respects the dynamic island boundaries as anticipated. Any considered find out how to repair this? What am I doing mistaken?

Textual content(timerInterval: Date()...context.state.endDate, countsDown: true, showsHours: true)
import ActivityKit
import SwiftUI
import WidgetKit

@obtainable(iOS 17.0, *)
struct CompactTrailingView: View {
    let context: ActivityViewContext<TimerAttributes>

    var physique: some View {
        if context.hasExpired || context.state.isPaused {
            Textual content(formattedTime)
                .font(.Widget.heading2Regular14.monospacedDigit())
                .foregroundColor(.white)
                .monospacedDigit()
        } else {
            Textual content(timerInterval: Date()...context.state.endDate, countsDown: true, showsHours: true)
                .font(.Widget.heading2Regular14.monospacedDigit())
                .foregroundColor(.white)
                .monospacedDigit()
                .multilineTextAlignment(.trailing)
        }
    }
    
    
    var formattedTime: String {
        if context.hasExpired {
            return "00:00"
        }

        let remaining = max(context.state.remainingDuration, 0)

        let hours = Int(remaining) / 3600
        let minutes = Int(remaining) / 60 % 60
        let seconds = Int(remaining) % 60
        
        if hours == 0 {
            return String(format: "%02d:%02d", minutes, seconds)
        }

        return String(format: "%02d:%02d:%02d", hours, minutes, seconds)
    }
}

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments