London Escorts sunderland escorts 1v1.lol unblocked yohoho 76 https://www.symbaloo.com/mix/yohoho?lang=EN yohoho https://www.symbaloo.com/mix/agariounblockedpvp https://yohoho-io.app/ https://www.symbaloo.com/mix/agariounblockedschool1?lang=EN
-7.3 C
New York
Sunday, February 2, 2025

ios – Clickable horizontal calendar with SwiftUI


I am making an attempt to make a scheme during which I’ve 7 fastened days above, the present day is at all times the center one, however I would prefer to make the opposite days clickable too, in order that whenever you click on on the day the cardboard under modifications with the corresponding descriptions, as if every one had been linked to a selected day. I managed to set the times, however I am unable to determine if I would like to make use of a state or one thing just like make them clickable.

At first I attempted utilizing state and manipulating it in zstack, nevertheless it did not work.

import SwiftUI

struct DayPlanView: View {
    @State var monthString: String = "Not Set"

    let calendar = Calendar.present
     

    var physique: some View {
        let dates = getWeek()
        
        VStack {
            // MARK: Change Date() to some identifier of chosen date.
            HStack {
                Textual content("(getDayNumber(date: Date()))")
                    .font(.title2)
                    .fontWeight(.semibold)
                Textual content("of")
                    .font(.title2)
                    .fontWeight(.semibold)
                Textual content(getMonth(date: Date()))
                    .font(.title2)
                    .fontWeight(.semibold)
            }
            
            HStack {
                ForEach(dates, id: .self) { day in
                    VStack {


                        let dayNumber = getDayNumber(date: day)
                        
                        if dayNumber == getDayNumber(date: Date()) {
                            ZStack {
                                Circle()
                                    .fill(.blue)
                                    .scaleEffect(1.3)
                                
                                Textual content("(getDayNumber(date: day))")
                                    .font(.title)
                                    .fontWeight(.semibold)
                                    .foregroundColor(.white)
                            }
                        } else {
                            Textual content("(getDayNumber(date: day))")
                               .font(.title)
                        }
                    }
                    .body(width: getWidth() / 8, top: getHeight() / 20)
                    .padding(.horizontal, -3)
               }
            }
           .body(width: getWidth())
            Spacer()
        }
        .padding(.vertical, getHeight() / 20)
    }
    
    func getMonth(date: Date) -> String {
        let dateFormatter = DateFormatter()
        dateFormatter.dateFormat = "LLLL"
        return dateFormatter.string(from: date)
    }

    func getDayShort(date: Date) -> String {
        let dateFormatter = DateFormatter()
        dateFormatter.dateFormat = "E"
        return dateFormatter.string(from: date)
    }
    
    func getDayNumber(date: Date) -> Int {
        let calendar = Calendar.present
        let parts = calendar.dateComponents([.day], from: date)
        return parts.day ?? 0
    }

    func getWeek() -> [Date] {
        let currentDate = Date()

        let calendar = Calendar.present
        let dayOfWeek = calendar.element(.weekday, from: currentDate)
        
        let vary = calendar.vary(of: .day, in: .month, for: currentDate)!
        
        let daysMonth = (vary.lowerBound - 1 ..< vary.lowerBound + 6)
            .compactMap { calendar.date(byAdding: .day, worth: $0 - dayOfWeek, to: currentDate) }
        
        return daysMonth
    }
}

struct DayPlanView_Previews: PreviewProvider {
    static var previews: some View {
        DayPlanView()
    }
}

the display screen I am working

Related Articles

Social Media Auto Publish Powered By : XYZScripts.com