Skip to content

Commit 4bac098

Browse files
feat: add map example
1 parent fbd4aca commit 4bac098

File tree

9 files changed

+502
-8
lines changed

9 files changed

+502
-8
lines changed

Project.swift

+4-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import ProjectDescription
66
import ProjectDescriptionHelpers
77

8-
private let deploymentTargetVersion = "17.0"
8+
private let deploymentTargetVersion = "18.0"
99

1010
let project = Project.app(
1111
name: Constants.projectName,
@@ -68,8 +68,9 @@ let project = Project.app(
6868
"UIFileSharingEnabled": "TRUE",
6969
"UIApplicationSupportsIndirectInputEvents": "TRUE",
7070

71-
"NSCameraUsageDescription": "Record video",
72-
"NSMicrophoneUsageDescription": "Record audio"
71+
"NSCameraUsageDescription": "Camera permission is needed to record video.",
72+
"NSMicrophoneUsageDescription": "Microphone permission is needed to record audio.",
73+
"NSLocationWhenInUseUsageDescription": "Location permission is needed to show your current location."
7374
],
7475
configInfoPlist: [
7576
"CONF_HOST_URL": "$(XCC_HOST_URL)"

README.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -302,15 +302,11 @@ let image: UIImage = CoreAsset.exampleImage.image // Access from any target :)
302302
- [ ] CMS Module
303303
- [ ] System UI Components Collection
304304
- [ ] (Grid)[https://developer.apple.com/documentation/swiftui/grid]
305-
- [x] Navigation system update
306305
- [ ] SF Symbol animation ((How to animate SF Symbols)[https://www.hackingwithswift.com/quick-start/swiftui/how-to-animate-sf-symbols])
307-
- [x] Migrate to Tuist
308-
- [x] Migrate to Tuist 4.0
309306
- [ ] Fix a freeze issue in `NavigationView` inside `NavigationStack`
310-
- [x] Add `ShimmerUI`
311-
- [x] Update `Backend`
312307
- [ ] Update `ShimmerUI`
313308
- [ ] Update `Tuist` docs ("Access Assets" section etc.)
309+
- [ ] Add map example with current location access
314310

315311
## Extensions
316312

Targets/Home/Sources/UI/Screens/Home/Model/Screen.swift

+4
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ struct Screen: Identifiable, Sendable {
114114
name: "`Ollama` Example",
115115
destination: Destination.Ollama()
116116
),
117+
Screen(
118+
name: "Map Example",
119+
destination: Destination.Map()
120+
),
117121
].sorted { old, new in
118122
old.name.filter { $0.isLetter || $0.isNumber } < new.name.filter { $0.isLetter || $0.isNumber }
119123
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
//
2+
// Copyright © 2025 Md. Mahmudul Hasan Shohag. All rights reserved.
3+
//
4+
5+
import SwiftUI
6+
7+
struct LocationAuthorizationPreAlertSection: View {
8+
let onClickAllow: () -> Void
9+
10+
var body: some View {
11+
ScrollView {
12+
ZStack {
13+
Spacer().containerRelativeFrame([.horizontal, .vertical])
14+
15+
VStack(alignment: .center) {
16+
Image(systemName: "location.fill.viewfinder")
17+
.resizable()
18+
.frame(width: 64, height: 64)
19+
.font(.title)
20+
21+
Spacer()
22+
.frame(height: 32)
23+
24+
Text("Turn on location service to show your current location on the map.")
25+
.font(.title)
26+
27+
IconTextSection(
28+
systemIcon: "heart.fill",
29+
text: "Lorem Ipsum Dolor Sit Amet Consectetur Adipiscing Elit Aenean Quis"
30+
)
31+
32+
IconTextSection(
33+
systemIcon: "map.fill",
34+
text: "Lorem Ipsum Dolor Sit Amet Consectetur Adipiscing Elit Aenean Quis"
35+
)
36+
37+
IconTextSection(
38+
systemIcon: "chart.bar.doc.horizontal.fill",
39+
text: "Lorem Ipsum Dolor Sit Amet Consectetur Adipiscing Elit Aenean Quis"
40+
)
41+
42+
Spacer()
43+
.frame(height: 16)
44+
45+
Button {
46+
onClickAllow()
47+
} label: {
48+
Text("Allow")
49+
.frame(maxWidth: .infinity)
50+
}
51+
.buttonStyle(.borderedProminent)
52+
.buttonBorderShape(.capsule)
53+
.font(.title)
54+
.tint(Color.white)
55+
.foregroundStyle(Color.pink)
56+
}
57+
.padding()
58+
.multilineTextAlignment(.center)
59+
.foregroundStyle(Color.white)
60+
.frame(maxWidth: .infinity, maxHeight: .infinity)
61+
}
62+
}
63+
.background(
64+
ZStack {
65+
Color.pink
66+
}
67+
.overlay(Gradient(colors: [Color.clear, Color.black.opacity(0.5)]))
68+
.ignoresSafeArea()
69+
)
70+
}
71+
}
72+
73+
private struct IconTextSection: View {
74+
let systemIcon: String
75+
let text: String
76+
77+
var body: some View {
78+
HStack(spacing: 16) {
79+
Image(systemName: systemIcon)
80+
.resizable()
81+
.padding(12)
82+
.background(Color.white)
83+
.foregroundStyle(Color.pink)
84+
.clipShape(Circle())
85+
.frame(width: 48, height: 48)
86+
87+
Text(text)
88+
.font(.body)
89+
.multilineTextAlignment(.leading)
90+
}
91+
.padding()
92+
}
93+
}
94+
95+
#Preview {
96+
LocationAuthorizationPreAlertSection(
97+
onClickAllow: {}
98+
)
99+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
//
2+
// Copyright © 2025 Md. Mahmudul Hasan Shohag. All rights reserved.
3+
//
4+
5+
import SwiftUI
6+
7+
struct MapPlaceDetailsSheet: View {
8+
let item: MapPlace
9+
10+
var body: some View {
11+
ScrollView {
12+
VStack(spacing: 0) {
13+
GeometryReader { proxy in
14+
AsyncImage(
15+
url: URL(
16+
string: "https://picsum.photos/seed/\(item.name)/300/300"
17+
),
18+
content: { image in
19+
image.resizable()
20+
.scaledToFill()
21+
.frame(
22+
width: proxy.size.width,
23+
height: proxy.size.height
24+
)
25+
.clipped()
26+
},
27+
placeholder: {
28+
ProgressView()
29+
.frame(
30+
width: proxy.size.width,
31+
height: proxy.size.height
32+
)
33+
}
34+
)
35+
}
36+
.frame(maxWidth: .infinity)
37+
.aspectRatio(3, contentMode: .fit)
38+
.background(Color.gray.opacity(0.5))
39+
40+
VStack(spacing: 8) {
41+
Text(item.name)
42+
.font(.title)
43+
Text("\(item.location.latitude), \(item.location.longitude)")
44+
.font(.subheadline)
45+
Text(item.description)
46+
}
47+
.padding()
48+
}
49+
.multilineTextAlignment(.center)
50+
}
51+
}
52+
}
53+
54+
#Preview {
55+
ZStack {}
56+
.sheet(isPresented: .constant(true)) {
57+
MapPlaceDetailsSheet(item: MapPlace.places.first!)
58+
.presentationDragIndicator(.visible)
59+
.presentationDetents([.medium])
60+
}
61+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
//
2+
// Copyright © 2025 Md. Mahmudul Hasan Shohag. All rights reserved.
3+
//
4+
5+
import SwiftUI
6+
7+
struct MapWarningView<Content: View>: View {
8+
@ViewBuilder let content: () -> Content
9+
10+
var body: some View {
11+
VStack {
12+
content()
13+
}
14+
.multilineTextAlignment(.center)
15+
.frame(maxWidth: .infinity)
16+
.padding()
17+
.background {
18+
RoundedRectangle(cornerRadius: 16)
19+
.stroke(Color.yellow, lineWidth: 2)
20+
}
21+
.background(Color.yellow.opacity(0.25))
22+
.background(Color.systemBackground)
23+
.clipShape(RoundedRectangle(cornerRadius: 16))
24+
}
25+
}
26+
27+
#Preview {
28+
VStack {
29+
MapWarningView {
30+
Text("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s")
31+
32+
Button {
33+
//
34+
} label: {
35+
Text("Lorem Ipsum")
36+
}
37+
}
38+
.padding()
39+
40+
MapWarningView {
41+
Text("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s")
42+
43+
Button {
44+
//
45+
} label: {
46+
Text("Lorem Ipsum")
47+
}
48+
}
49+
.padding()
50+
}
51+
.background(Color.blue)
52+
}

0 commit comments

Comments
 (0)