// // ContentView.swift // sdsz74 // // Created by yunli on 2023/5/18. // import SwiftUI struct ContentView: View { @State private var examCount = 0 @State private var messageCount = 0 @State private var isLoggedIn = 0 @State private var userInfo: UserInfo = .init() var body: some View { TabView { NavigationView { NavigationLink(destination: examListView(count: $examCount)) { Text("共 \(examCount) 场考试") } .navigationBarTitle("74 桌") } .tabItem { Image(systemName: "chart.bar.fill") Text("成绩分析") } NavigationView { List { Section { NavigationLink(destination: messageView(count: $messageCount)) { Text("消息") .badge(messageCount) } } Section { ForEach(0 ..< userInfo.tableData.count, id: \.self) { i in HStack { ForEach(0 ..< userInfo.tableData[i].count, id: \.self) { j in if userInfo.tableData[i][j].data.count != 0 { Text("\(userInfo.tableData[i][j].data[0].courseName.replacing("高中", with: "").replacing("实践类", with: "").replacing("语文阅读", with: "阅读"))") } else { Text("  ").frame(minWidth: 10) } } } } } // for i in 0 ..< 5 { // if userInfo.tableData.count > i { // Text("\(userInfo.tableData[i].data[0].courseName)") // } // ForEach(0 ..< userInfo.tableData.filter { $0.day == i }.count, id: \.self) { i in // Text("\(userInfo.tableData[i].day)\(userInfo.tableData[i].lesson)\(userInfo.tableData[i].data[0].courseName.replacing("高中", with: "").replacing("实践类", with: ""))") // } // } } .navigationBarTitle("数字校园") } .tabItem { Image(systemName: "graduationcap") Text("数字校园") } NavigationView { if isLoggedIn != 0 { accountView(isLoggedIn: $isLoggedIn, userInfo: $userInfo) .navigationBarTitle("账号") } else { loginView(isLoggedIn: $isLoggedIn, userInfo: $userInfo) .navigationBarTitle("登录") } } .tabItem { Image(systemName: "person") Text("账号") } } } } extension View { func hideKeyboard() { UIApplication.shared.sendAction( #selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil ) } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } }