Skip to content

Commit d7ccd68

Browse files
committed
[FileManager] Remove List component
1 parent fed87d0 commit d7ccd68

File tree

5 files changed

+74
-60
lines changed

5 files changed

+74
-60
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ extension FileManagerView.FileManagerListing {
2525

2626
Spacer()
2727
}
28-
.frame(maxWidth: .infinity)
2928
}
3029
}
3130
}
31+
32+
#Preview {
33+
FileManagerView.FileManagerListing.EmptyFolder(onUpload: {})
34+
}

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,10 @@ fileprivate extension FileManagerView.FileManagerListing.FileListingOptions {
7474
@Binding var settings: FileManagerSettings
7575

7676
var body: some View {
77-
Button(
78-
action: {
79-
settings.isHiddenFilesShow.toggle()
80-
isPresented = false
81-
}
82-
) {
77+
Button(action: {
78+
settings.isHiddenFilesShow.toggle()
79+
isPresented = false
80+
}, label: {
8381
HStack(spacing: 8) {
8482
ZStack {
8583
Circle()
@@ -99,7 +97,7 @@ fileprivate extension FileManagerView.FileManagerListing.FileListingOptions {
9997
.foregroundColor(.primary)
10098
Spacer()
10199
}
102-
}
100+
})
103101
.padding(12)
104102
}
105103
}

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

Lines changed: 15 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,54 +9,35 @@ extension FileManagerView.FileManagerListing {
99

1010
let onTap: (ExtendedElement) -> Void
1111
let onDelete: (ExtendedElement) -> Void
12-
let onAction: (ExtendedElement) -> Void
12+
let onSelect: (ExtendedElement) -> Void
1313

1414
private let columns = [GridItem(.flexible()), GridItem(.flexible())]
1515

1616
var body: some View {
17-
Group {
18-
switch displayType {
19-
case .list:
17+
switch displayType {
18+
case .list:
19+
LazyVStack(spacing: 12) {
2020
ForEach(elements) { element in
2121
ElementRow(
2222
element: element,
2323
type: displayType,
24-
onAction: { onAction(element) }
24+
onAction: { onSelect(element) }
2525
)
2626
.onTapGesture { onTap(element) }
27-
.swipeActions {
28-
Button(role: .destructive) {
29-
onDelete(element)
30-
} label: {
31-
Image("Delete")
32-
.foregroundColor(.red)
33-
}
34-
.tint(.red.opacity(0.1))
35-
}
3627
}
37-
case .grid:
38-
LazyVGrid(columns: columns, spacing: 12) {
39-
ForEach(elements) { element in
40-
ElementRow(
41-
element: element,
42-
type: displayType,
43-
onAction: { onAction(element) }
44-
)
45-
.onTapGesture { onTap(element) }
46-
}
28+
}
29+
case .grid:
30+
LazyVGrid(columns: columns, spacing: 12) {
31+
ForEach(elements) { element in
32+
ElementRow(
33+
element: element,
34+
type: displayType,
35+
onAction: { onSelect(element) }
36+
)
37+
.onTapGesture { onTap(element) }
4738
}
4839
}
4940
}
50-
.listRowSeparator(.hidden)
51-
.listRowInsets(
52-
.init(
53-
top: 0,
54-
leading: 0,
55-
bottom: 0,
56-
trailing: 0
57-
)
58-
)
59-
.listRowBackground(Color.clear)
6041
}
6142
}
6243
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ extension FileManagerView {
2020
gradient: Gradient(
2121
stops: [
2222
Gradient.Stop(color: .background, location: 0.2),
23-
Gradient.Stop(color: .clear, location: 1),
23+
Gradient.Stop(color: .clear, location: 1)
2424
]
2525
),
2626
startPoint: .leading,
@@ -69,6 +69,7 @@ extension FileManagerView {
6969
.frame(width: 8, height: 24)
7070
}
7171
}
72+
.padding(4)
7273
}
7374

7475
private func navigate(to index: Int) {

Flipper/iOS/UI/FileManager/FileManagerListing.swift

Lines changed: 48 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,32 +43,37 @@ extension FileManagerView {
4343
}
4444

4545
var body: some View {
46-
VStack {
46+
Group {
4747
if let error = error {
4848
Text(error)
4949
} else if isLoading {
5050
ProgressView()
5151
} else {
52-
List {
53-
if path.isRoot {
54-
SDCardInfo(storage: storage)
55-
} else {
56-
NavigationPathView(path: path)
52+
FixedScrollView(showsIndicators: false) {
53+
Group {
54+
if path.isRoot {
55+
SDCardInfo(storage: storage)
56+
} else {
57+
NavigationPathView(path: path)
58+
}
5759
}
60+
.padding([.horizontal, .top], 14)
5861

59-
if elements.isEmpty {
60-
EmptyFolder(onUpload: showUpload)
61-
} else {
62-
FileManagerElements(
63-
elements: elements,
64-
displayType: settings.displayType,
65-
onTap: navigate,
66-
onDelete: { deleteFile($0) },
67-
onAction: { selectedElement = $0 }
68-
)
62+
Group {
63+
if elements.isEmpty {
64+
EmptyFolder(onUpload: showUpload)
65+
} else {
66+
FileManagerElements(
67+
elements: elements,
68+
displayType: settings.displayType,
69+
onTap: navigate,
70+
onDelete: { deleteFile($0) },
71+
onSelect: { selectedElement = $0 }
72+
)
73+
}
6974
}
75+
.padding(14)
7076
}
71-
.listRowSpacing(12)
7277
}
7378
}
7479
.frame(maxWidth: .infinity, maxHeight: .infinity)
@@ -232,3 +237,29 @@ fileprivate extension Peripheral.Path {
232237
self == "/ext"
233238
}
234239
}
240+
241+
private struct FixedScrollView<Content: View>: View {
242+
let showsIndicators: Bool
243+
let content: () -> Content
244+
245+
init(
246+
showsIndicators: Bool,
247+
@ViewBuilder content: @escaping () -> Content
248+
) {
249+
self.showsIndicators = showsIndicators
250+
self.content = content
251+
}
252+
253+
var body: some View {
254+
GeometryReader { geometry in
255+
ScrollView(showsIndicators: showsIndicators) {
256+
VStack(spacing: 0) {
257+
content()
258+
Spacer()
259+
}
260+
.frame(minHeight: geometry.size.height)
261+
}
262+
.frame(width: geometry.size.width)
263+
}
264+
}
265+
}

0 commit comments

Comments
 (0)