55 lines
1.5 KiB
Swift
55 lines
1.5 KiB
Swift
//
|
|
// UserAvatarView.swift
|
|
// demo
|
|
//
|
|
// Created by Jason on 2024/1/25.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct UserAvatarView: View {
|
|
@Environment(\.dismiss) private var dismiss
|
|
|
|
@State private var showSheet = false
|
|
|
|
var body: some View {
|
|
VStack {
|
|
Image("Images/banner1")
|
|
.resizable()
|
|
.aspectRatio(contentMode: .fit)
|
|
.frame(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.width)
|
|
}
|
|
.toolbar {
|
|
ToolbarItem(placement: .navigationBarLeading) {
|
|
Button {
|
|
dismiss()
|
|
} label: {
|
|
Image(systemName: "chevron.backward")
|
|
}
|
|
}
|
|
|
|
ToolbarItem(placement: .navigationBarTrailing) {
|
|
Button {
|
|
showSheet = true
|
|
} label: {
|
|
Image(systemName: "ellipsis")
|
|
}
|
|
.actionSheet(isPresented: $showSheet, content: {
|
|
ActionSheet(title: Text("更换头像"), message: nil, buttons: [
|
|
.default(Text("从相册选择"), action: {}),
|
|
.default(Text("拍一张"), action: {}),
|
|
.cancel(Text("取消"))
|
|
])
|
|
})
|
|
}
|
|
}
|
|
.navigationBarBackButtonHidden(true)
|
|
.navigationBarTitleDisplayMode(.inline)
|
|
.navigationTitle("头像")
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
UserAvatarView()
|
|
}
|