123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- //
- // 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 {
- NavigationLink(destination: messageView(count: $messageCount)) {
- Text("消息")
- .badge(messageCount)
- }
- // 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()
- }
- }
|