pushdeer/ios/PushDeer-iOS/PushDeer/View/DeviceListView.swift
2021-12-27 22:33:27 +08:00

46 lines
1.1 KiB
Swift

//
// DeviceListView.swift
// PushDeer
//
// Created by HEXT on 2021/12/25.
//
import SwiftUI
///
struct DeviceListView: View {
@State var devices = Array(0..<10)
var body: some View {
BaseNavigationView(title: "设备") {
ScrollView {
LazyVStack(alignment: .center) {
ForEach(devices, id: \.self) { name in
DeletableView(contentView: {
DeviceItemView(name: "设备 \(name)")
}, deleteAction: {
devices.removeAll { _name in
_name == name
}
})
.padding(EdgeInsets(top: 18, leading: 26, bottom: 0, trailing: 24))
}
}
}
.navigationBarItems(trailing: Button(action: {
withAnimation(.easeOut) {
devices.insert(Int(arc4random_uniform(1000)), at: 0)
}
}, label: {
Image(systemName: "plus")
.foregroundColor(Color(UIColor.lightGray))
}))
}
}
}
struct DeviceView_Previews: PreviewProvider {
static var previews: some View {
DeviceListView()
}
}