当前位置:网站首页>Chat聊天App第6节课创建主聊天静态页面
Chat聊天App第6节课创建主聊天静态页面
2022-04-22 10:53:00 【JohnsonSwift】
Chat聊天App第6节课创建主聊天静态页面

核心源码:
//
// MainMessageView.swift
// LuJunChatDemo
//
// Created by lujun on 2022/4/20.
//
import SwiftUI
struct MainMessageView: View {
@State var shouldShowLogOutOptions = false
var body: some View {
NavigationView{
VStack {
customNavBar
messagesView
.overlay(newMessageButton,alignment: .bottom)
}
.navigationBarHidden(true)
.navigationTitle("消息")
}
}
}
struct MainMessageView_Previews: PreviewProvider {
static var previews: some View {
MainMessageView()
}
}
extension MainMessageView {
private var customNavBar: some View {
HStack{
Image(systemName: "person.fill")
.font(.system(size: 34,weight: .heavy))
VStack(alignment: .leading,spacing: 4){
Text("鲁军")
.font(.system(size: 24,weight: .bold))
HStack{
Circle()
.foregroundColor(.green)
.frame(width: 14, height: 14)
Text("在线")
.font(.system(size: 12))
.foregroundColor(Color(.lightGray))
}
}
Spacer()
Button {
shouldShowLogOutOptions.toggle()
} label: {
Image(systemName: "gear")
.foregroundColor(.black)
.font(.system(size: 24, weight: .bold))
}
}
.padding()
.confirmationDialog(
"注销警告?",
isPresented: $shouldShowLogOutOptions,
titleVisibility: .visible) {
Button("注销", role: .destructive) {
// Handle empty trash action.
}
} message: {
Text("你想做什么?")
}
}
private var messagesView: some View {
ScrollView{
ForEach(0...12,id:\.self){
item in
VStack{
HStack{
Image(systemName: "person.fill")
.font(.system(size: 32))
.padding(8)
.overlay(
RoundedRectangle(cornerRadius: 44)
.stroke(Color.black,lineWidth: 1)
)
VStack(alignment: .leading){
Text("用户名")
.font(.system(size: 16,weight: .bold))
Text("发消息给xxx")
.font(.system(size: 14))
.foregroundColor(Color(.lightGray))
}
Spacer()
Text("xxx")
.font(.system(size: 14,weight: .semibold))
}
Divider()
.padding(.vertical,8)
}
.padding(.horizontal)
}
.padding(.bottom,50)
}
}
private var newMessageButton: some View {
Button {
} label: {
HStack{
Spacer()
Text("+ 新消息")
.font(.system(size: 16,weight: .bold))
Spacer()
}
.foregroundColor(.white)
.padding(.vertical)
.background(Color.blue)
.cornerRadius(32)
.padding(.horizontal)
.shadow(radius: 15)
}
}
}
希望点赞收藏!
版权声明
本文为[JohnsonSwift]所创,转载请带上原文链接,感谢
https://blog.csdn.net/A1521315qwss/article/details/124311462
边栏推荐
- C language advanced level 1 ------ "data storage (original code inverse code complement + size end judgment + integer promotion + floating point number storage)
- Secondary vocational network security D - file upload
- PHP gets the IP and limits the submission times in minutes, which is suitable for too frequent acquisition of verification code
- Daily CISSP certification common mistakes (April 21, 2022)
- Que sait la commande ADB? Les ordres de la BAD arrivent.
- qDebug()打印调试信息
- 文章84:投资最重要的事是安全框架:猪周期结束,畜牧成为两市唯一确定板块(框架思维)
- 2022渗透岗位面试(思路篇)
- dnspy 修改 伊格利亚战记 军队维护费和英雄维护系数
- ffmpeg filtergraph同时添加缩放和osd滤镜
猜你喜欢
随机推荐
Menu bar, toolbar and status bar of QT
TC397 MCMCAN
Matlab 2009 installation tutorial
蔡国强烟花NFT首发,白天烟花一样精彩
360 released the annual report: the operating revenue was about 10.886 billion yuan, and the security business increased by more than 70%
php 获取IP以分钟限制提交次数,适用于验证码获取过于频繁
PCIE XDMA IP核介绍(附列表)-明德扬科教(mdy-edu.com)
110t Oracle fault recovery
十年测试经验,我整理出了最适合你的软件测试学习指南
pytorch语义分割-全卷积网络
Synchronized锁及其膨胀
[leetcode] the first mock exam of two tree traversal iteration method.
Spa first screen loading optimization
Devsecops software R & D security practice - Design
2022软件测试好学吗,大概要学多久?(附学习路线图)
TC397 EVADC
2022-04-19_ Function (II)
CVPR 2022 | 用Transformer学习多假设表示!3D人体姿态估计的新框架!
C语言实例100(四)
C language example 100 (IV)









