pushdeer/ios/PushDeer-iOS/PushDeer/View/MessageListView.swift

70 lines
1.6 KiB
Swift
Raw Normal View History

2021-12-27 22:33:27 +08:00
//
// MessageListView.swift
// PushDeer
//
// Created by HEXT on 2021/12/25.
//
import SwiftUI
///
struct MessageListView: View {
2022-01-04 22:28:18 +08:00
@State private var messages = Array(0..<10)
@State private var isShowTest = true
2021-12-27 22:33:27 +08:00
var body: some View {
2022-01-04 22:28:18 +08:00
BaseNavigationView(title: "消息") {
ScrollView {
LazyVStack(alignment: .leading) {
if isShowTest {
TestPushView()
}
ForEach(messages, id: \.self) { msg in
MessageItemView {
messages.removeAll { _msg in
_msg == msg
}
}
}
Spacer(minLength: 30)
}
}
.navigationBarItems(trailing: Button(action: {
withAnimation(.easeOut) {
isShowTest = !isShowTest
}
}, label: {
Image(systemName: isShowTest ? "chevron.up" : "chevron.down")
.foregroundColor(Color(UIColor.lightGray))
}))
}
}
}
struct TestPushView: View {
@State private var testText = ""
var body: some View {
TextEditor(text: $testText)
.overlay(RoundedRectangle(cornerRadius: 4).stroke(Color.accentColor))
.frame(height: 128)
.padding(EdgeInsets(top: 18, leading: 26, bottom: 0, trailing: 24))
Button("推送测试") {
print("点击推送测试")
}
.font(.system(size: 20))
.frame(width: 104, height: 42)
.foregroundColor(Color.white)
.background(Color.accentColor)
.cornerRadius(8)
.padding(EdgeInsets(top: 12, leading: 26, bottom: 0, trailing: 24))
2021-12-27 22:33:27 +08:00
}
}
struct MessageView_Previews: PreviewProvider {
static var previews: some View {
MessageListView()
}
}