-
Notifications
You must be signed in to change notification settings - Fork 12
/
MODList.swift
68 lines (59 loc) · 1.41 KB
/
MODList.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
//
// MODList.swift
// my41
//
// Created by Miroslav Perovic on 3.2.21..
// Copyright © 2021 iPera. All rights reserved.
//
import SwiftUI
struct MODList: View {
@ObservedObject var settingsState: SettingsState
private let mods: [MOD] = Array(MODs.getModFiles().values)
@Binding var showList: Bool
@State private var selectedModule: MOD?
var port: HPPort
var body: some View {
VStack {
HStack {
Button(action: {
showList = false
}, label: {
Text("Cancel")
})
.padding([.top, .leading], 10)
Spacer()
Button(action: {
switch port {
case .port1:
settingsState.module1 = selectedModule
case .port2:
settingsState.module2 = selectedModule
case .port3:
settingsState.module3 = selectedModule
case .port4:
settingsState.module4 = selectedModule
}
showList = false
}, label: {
Text("Apply")
})
.padding([.top, .trailing], 10)
}
List {
ForEach(mods, id: \.self) { mod in
MODDetailsView(module: mod, short: false)
.onTapGesture {
selectedModule = mod
}
.listRowBackground(selectedModule == mod ? Color.gray.brightness(0.4) as! Color : Color.clear)
}
}
}
}
}
struct MODList_Previews: PreviewProvider {
@State static var showList = true
static var previews: some View {
MODList(settingsState: SettingsState(), showList: $showList, port: .port3)
}
}