Mercurial > public > lazybear
view LazyBear/Views/Home/TradingDates.swift @ 346:80bfa88c6b0f
Implementing Prop API
author | Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> |
---|---|
date | Sun, 11 Apr 2021 19:55:47 +0200 |
parents | e81c18164afb |
children | 5ccceb527178 |
line wrap: on
line source
// // TradingDate.swift // LazyBear // // Created by Dennis Concepción Martín on 30/3/21. // import SwiftUI struct TradingDates: View { var dates: [TradingDatesModel] var body: some View { NavigationView { ScrollView { VStack(spacing: 20) { ForEach(getArrayOfDates(), id: \.self) { date in TradingDatesItem(date: date) } } .padding() } .navigationTitle("Holiday dates") .navigationBarTitleDisplayMode(.inline) } } private func getArrayOfDates() -> [Date] { // Get array of the string dates let stringDates = self.dates.map { $0.date } // Convert string to date let dateFormatter = DateFormatter() dateFormatter.dateFormat = "yyyy-MM-dd" // Append dates to a Date array var dates = [Date]() for stringDate in stringDates { dates.append(dateFormatter.date(from: stringDate)!) } return dates } } struct TradingDate_Previews: PreviewProvider { static var previews: some View { // Format is YYYY-MM-DD TradingDates(dates: [TradingDatesModel(date: "2021-01-01")]) } }