Skip to content

Commit fed87d0

Browse files
committed
[FileManager] Gradient for navigation path
1 parent a69dfbb commit fed87d0

File tree

3 files changed

+89
-25
lines changed

3 files changed

+89
-25
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"images" : [
3+
{
4+
"filename" : "SDCardDummy.svg",
5+
"idiom" : "universal",
6+
"scale" : "1x"
7+
},
8+
{
9+
"idiom" : "universal",
10+
"scale" : "2x"
11+
},
12+
{
13+
"idiom" : "universal",
14+
"scale" : "3x"
15+
}
16+
],
17+
"info" : {
18+
"author" : "xcode",
19+
"version" : 1
20+
}
21+
}
Lines changed: 3 additions & 0 deletions
Loading

Flipper/iOS/UI/FileManager/Components/NavigationPathView.swift

Lines changed: 65 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,36 +15,58 @@ extension FileManagerView {
1515
.filter { $0 != "ext" }
1616
}
1717

18+
var gradient: LinearGradient {
19+
LinearGradient(
20+
gradient: Gradient(
21+
stops: [
22+
Gradient.Stop(color: .background, location: 0.2),
23+
Gradient.Stop(color: .clear, location: 1),
24+
]
25+
),
26+
startPoint: .leading,
27+
endPoint: .trailing
28+
)
29+
}
30+
1831
var body: some View {
19-
HStack(spacing: 8) {
20-
Image("SDCard")
32+
HStack(spacing: 0) {
33+
Image("SDCardDummy")
2134
.resizable()
2235
.renderingMode(.template)
23-
.frame(width: 24, height: 24)
36+
.frame(width: 20, height: 24)
2437
.foregroundColor(.primary)
2538
.onTapGesture { navigate(to: 0) }
2639

27-
Text("/")
28-
.font(.system(size: 14, weight: .bold))
29-
.foregroundColor(.black30)
40+
ZStack(alignment: .leading) {
41+
ScrollViewReader { proxy in
42+
ScrollView(.horizontal, showsIndicators: false) {
43+
HStack(spacing: 8) {
44+
Spacer()
45+
.frame(width: 0, height: 0)
3046

31-
ScrollViewReader { proxy in
32-
ScrollView(.horizontal, showsIndicators: false) {
33-
HStack(spacing: 8) {
34-
ForEach(components.indices, id: \.self) { index in
35-
Element(
36-
component: components[index],
37-
index: index,
38-
onTap: navigate
39-
)
47+
ForEach(
48+
components.indices,
49+
id: \.self
50+
) { index in
51+
Element(
52+
component: components[index],
53+
index: index,
54+
onTap: navigate
55+
)
56+
.id(index)
57+
}
4058
}
4159
}
42-
}
43-
.onAppear {
44-
if let lastIndex = components.indices.last {
45-
proxy.scrollTo(lastIndex, anchor: .trailing)
60+
.onAppear {
61+
if let lastIndex = components.indices.last {
62+
proxy.scrollTo(lastIndex, anchor: .trailing)
63+
}
4664
}
4765
}
66+
67+
Rectangle()
68+
.fill(gradient)
69+
.frame(width: 8, height: 24)
4870
}
4971
}
5072
}
@@ -64,18 +86,36 @@ fileprivate extension FileManagerView.NavigationPathView {
6486

6587
var body: some View {
6688
HStack(spacing: 8) {
67-
if index != 0 {
68-
Text("/")
69-
.font(.system(size: 14, weight: .bold))
70-
.foregroundColor(.black30)
71-
}
89+
Text("/")
90+
.font(.system(size: 14, weight: .bold))
91+
.foregroundColor(.black30)
7292

7393
Text(component)
7494
.font(.system(size: 16, weight: .bold))
7595
.foregroundColor(.primary)
7696
.onTapGesture { onTap(index + 1) }
7797
}
78-
.id(index)
7998
}
8099
}
81100
}
101+
102+
#Preview {
103+
VStack {
104+
FileManagerView.NavigationPathView(
105+
path: Peripheral.Path(string: "/ext/apps")
106+
)
107+
108+
FileManagerView.NavigationPathView(
109+
path: Peripheral.Path(string: "/ext/Downloads/2021/08/17")
110+
)
111+
112+
FileManagerView.NavigationPathView(
113+
path: Peripheral.Path(
114+
string: "/ext/Downloads/2021/08/17/dummy/test/file"
115+
)
116+
)
117+
}
118+
.environment(\.path, .constant(NavigationPath()))
119+
.padding(12)
120+
.background(Color.background)
121+
}

0 commit comments

Comments
 (0)