Skip to content

Commit f413576

Browse files
authored
Merge pull request #13 from juandahurt/story
feat: improve story view ui
2 parents 614c84e + 0e12624 commit f413576

File tree

2 files changed

+38
-35
lines changed

2 files changed

+38
-35
lines changed

PuraceDemo/PuraceDemo/Examples/Complex/StoryExample.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ struct StoryExample: View {
2929
title: "Third title",
3030
subtitle: "La Ajliyh dlkjsouoy ojsf del Cauca es una universidad pública de Colombia, sujeta a inspección y vigilancia por medio de la Ley 174Sholj ljlih osdfyán, "
3131
)
32-
])
32+
]).frame(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height * 0.55)
3333
Spacer()
3434
}
3535
}

Sources/Purace/Views/Complex/Story/PuraceStoryView.swift

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -37,44 +37,47 @@ public struct PuraceStoryView: View {
3737
}
3838

3939
public var body: some View {
40-
ZStack {
41-
PuraceImageView(url: stories[currentIndex].image)
42-
LinearGradient(gradient: Gradient(colors: [.clear, .black.opacity(0.35)]), startPoint: .top, endPoint: .center)
43-
VStack {
44-
Spacer()
45-
HStack {
46-
PuraceTextView(stories[currentIndex].title, fontSize: 16, textColor: .white, weight: .medium)
40+
GeometryReader { outterReader in
41+
ZStack {
42+
PuraceImageView(url: stories[currentIndex].image)
43+
.aspectRatio(contentMode: .fill)
44+
.frame(width: outterReader.size.width)
45+
Color.black.opacity(0.3)
46+
VStack(spacing: 8) {
4747
Spacer()
48-
}
49-
HStack {
50-
PuraceTextView(stories[currentIndex].subtitle, fontSize: 12, textColor: .white)
48+
HStack {
49+
PuraceTextView(stories[currentIndex].title, fontSize: 18, textColor: .white, weight: .medium)
50+
Spacer()
51+
}
52+
HStack {
53+
PuraceTextView(stories[currentIndex].subtitle, fontSize: 14, textColor: .white)
54+
Spacer()
55+
}
56+
}.padding()
57+
VStack {
58+
indicators
5159
Spacer()
5260
}
53-
}.padding()
54-
VStack {
55-
indicators
56-
Spacer()
57-
}
58-
.padding(5)
59-
GeometryReader { geometry in
60-
HStack {
61-
Color.gray
62-
.opacity(0.001)
63-
.frame(width: geometry.size.width * 0.4)
64-
.onTapGesture {
65-
back()
66-
}
67-
Spacer()
68-
Color.gray // When opacity = 0 or the color is `clear`, tap gesture doesn't work :c
69-
.opacity(0.001)
70-
.frame(width: geometry.size.width * 0.4)
71-
.onTapGesture {
72-
next()
73-
}
61+
.padding(5)
62+
GeometryReader { innerReader in
63+
HStack {
64+
Color.gray
65+
.opacity(0.001)
66+
.frame(width: innerReader.size.width * 0.4)
67+
.onTapGesture {
68+
back()
69+
}
70+
Spacer()
71+
Color.gray // When opacity = 0 or the color is `clear`, tap gesture doesn't work :c
72+
.opacity(0.001)
73+
.frame(width: innerReader.size.width * 0.4)
74+
.onTapGesture {
75+
next()
76+
}
77+
}
78+
7479
}
75-
7680
}
77-
}.frame(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height * 0.33)
78-
81+
}
7982
}
8083
}

0 commit comments

Comments
 (0)