ContentView.swift 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. //
  2. // ContentView.swift
  3. // sdsz74
  4. //
  5. // Created by yunli on 2023/5/18.
  6. //
  7. import SwiftUI
  8. struct ContentView: View {
  9. @State private var examCount = 0
  10. @State private var messageCount = 0
  11. @State private var isLoggedIn = 0
  12. @State private var userInfo: UserInfo = .init(name: "...", o: "")
  13. var body: some View {
  14. TabView {
  15. NavigationView {
  16. NavigationLink(destination: examListView(count: $examCount)) {
  17. Text("共 \(examCount) 场考试")
  18. }
  19. .navigationBarTitle("74 桌")
  20. }
  21. .tabItem { Image(systemName: "chart.bar.fill")
  22. Text("成绩分析")
  23. }
  24. NavigationView {
  25. List {
  26. NavigationLink(destination: messageView(count: $messageCount)) {
  27. Text("消息")
  28. .badge(messageCount)
  29. }
  30. }
  31. .navigationBarTitle("数字校园")
  32. }
  33. .tabItem { Image(systemName: "graduationcap")
  34. Text("数字校园")
  35. }
  36. NavigationView {
  37. if isLoggedIn != 0 {
  38. accountView(isLoggedIn: $isLoggedIn, userInfo: $userInfo)
  39. .navigationBarTitle("账号")
  40. } else {
  41. loginView(isLoggedIn: $isLoggedIn, userInfo: $userInfo)
  42. .navigationBarTitle("登录")
  43. }
  44. }
  45. .tabItem { Image(systemName: "person")
  46. Text("账号")
  47. }
  48. }
  49. }
  50. }
  51. extension View {
  52. func hideKeyboard() {
  53. UIApplication.shared.sendAction(
  54. #selector(UIResponder.resignFirstResponder),
  55. to: nil,
  56. from: nil,
  57. for: nil
  58. )
  59. }
  60. }
  61. //
  62. // struct ContentView_Previews: PreviewProvider {
  63. // static var previews: some View {
  64. // ContentView()
  65. // }
  66. // }