-
Notifications
You must be signed in to change notification settings - Fork 1
/
HorizontalIcons.swift
73 lines (63 loc) · 2.18 KB
/
HorizontalIcons.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//
// HorizontalIcons.swift
// TikTokFavourites
//
import SwiftUI
struct IconTextPairView: View {
var body: some View {
ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: 40) {
ForEach(iconTextPairs, id: \.self) { pair in
NavigationLink(destination: DetailView(pair: pair)) {
VStack {
Image(systemName: pair.iconName)
.font(.largeTitle)
.foregroundColor(.black)
Text(pair.text)
.font(.caption)
.multilineTextAlignment(.center)
}
}
}
}
.padding()
}
}
}
struct IconTextPair: Identifiable, Hashable {
var id = UUID()
var iconName: String
var text: String
}
let iconTextPairs: [IconTextPair] = [
IconTextPair(iconName: "list.clipboard", text: "Orders"),
IconTextPair(iconName: "ticket", text: "Coupons"),
IconTextPair(iconName: "message", text: "Messages"),
IconTextPair(iconName: "bookmark", text: "Favourites"),
IconTextPair(iconName: "clock.arrow.circlepath", text: "History"),
IconTextPair(iconName: "mappin.and.ellipse", text: "Address"),
IconTextPair(iconName: "dollarsign.circle", text: "Payment"),
IconTextPair(iconName: "questionmark.circle", text: "Help")
]
struct DetailView: View {
let pair: IconTextPair
var body: some View {
if (pair.text != "Favourites") {
VStack {
Text("Detail Page")
.font(.title)
.padding()
Image(systemName: pair.iconName)
.font(.largeTitle)
.foregroundColor(.blue)
Text(pair.text)
.font(.caption)
.multilineTextAlignment(.center)
// Add more details or content here
}
.navigationBarTitle(pair.text, displayMode: .inline)
} else {
FavouritesPage()
}
}
}