Mercurial > public > lazybear
comparison LazyBear/Views/Home/Helpers/TradingDatesItem.swift @ 411:681fb377235e
Implementing insider transactions
author | Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> |
---|---|
date | Mon, 07 Jun 2021 20:59:52 +0200 |
parents | 09d05e48462f |
children | 2984d8946342 |
comparison
equal
deleted
inserted
replaced
410:e24c9ca71824 | 411:681fb377235e |
---|---|
15 RoundedRectangle(cornerRadius: 20) | 15 RoundedRectangle(cornerRadius: 20) |
16 .foregroundColor(Color(.secondarySystemBackground)) | 16 .foregroundColor(Color(.secondarySystemBackground)) |
17 .frame(width: 100, height: 100) | 17 .frame(width: 100, height: 100) |
18 .overlay( | 18 .overlay( |
19 VStack { | 19 VStack { |
20 Text(get(.month)) | 20 Text(getDateComponents(.month, date)) |
21 .fontWeight(.semibold) | 21 .fontWeight(.semibold) |
22 | 22 |
23 Text(get(.day)) | 23 Text(getDateComponents(.day, date)) |
24 .font(.title) | 24 .font(.title) |
25 .fontWeight(.semibold) | 25 .fontWeight(.semibold) |
26 .foregroundColor(Color("default")) | 26 .foregroundColor(Color("default")) |
27 | 27 |
28 Text(get(.year)) | 28 Text(getDateComponents(.year, date)) |
29 .font(.caption) | 29 .font(.caption) |
30 .fontWeight(.semibold) | 30 .fontWeight(.semibold) |
31 } | 31 } |
32 ) | 32 ) |
33 } | |
34 | |
35 private enum Components { | |
36 case day, month, year | |
37 } | |
38 | |
39 private func get(_ components: Components) -> String { | |
40 let dateComponents = Calendar.current.dateComponents([.year, .month, .day], from: date) | |
41 | |
42 switch components { | |
43 case .year: | |
44 return "\(dateComponents.year ?? 2020)" | |
45 case .day: | |
46 return "\(dateComponents.day ?? 1)" | |
47 case .month: | |
48 let dateFormatter = DateFormatter() | |
49 let monthNumber = dateComponents.month ?? 1 | |
50 let monthLetters = dateFormatter.shortMonthSymbols[monthNumber-1] | |
51 | |
52 return "\(monthLetters)" | |
53 } | |
54 | |
55 } | 33 } |
56 } | 34 } |
57 | 35 |
58 struct TradingDatesItem_Previews: PreviewProvider { | 36 struct TradingDatesItem_Previews: PreviewProvider { |
59 static var previews: some View { | 37 static var previews: some View { |