ContentView.swift 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. var body: some View {
  13. TabView {
  14. NavigationView {
  15. NavigationLink(destination: examListView(count: $examCount)) {
  16. Text("共 \(examCount) 场考试")
  17. }
  18. .navigationBarTitle("74 桌")
  19. }
  20. .tabItem { Image(systemName: "chart.bar.fill")
  21. Text("成绩分析")
  22. }
  23. NavigationView {
  24. List {
  25. NavigationLink(destination: messageView(count: $messageCount)) {
  26. Text("消息")
  27. .badge(messageCount)
  28. }
  29. }
  30. .navigationBarTitle("数字校园")
  31. }
  32. .tabItem { Image(systemName: "graduationcap")
  33. Text("数字校园")
  34. }
  35. NavigationView {
  36. if isLoggedIn != 0 {
  37. accountView(isLoggedIn: $isLoggedIn)
  38. .navigationBarTitle("账号")
  39. } else {
  40. loginView(isLoggedIn: $isLoggedIn)
  41. .navigationBarTitle("登录")
  42. }
  43. }
  44. .tabItem { Image(systemName: "person")
  45. Text("账号")
  46. }
  47. }
  48. }
  49. }
  50. extension View {
  51. func hideKeyboard() {
  52. UIApplication.shared.sendAction(
  53. #selector(UIResponder.resignFirstResponder),
  54. to: nil,
  55. from: nil,
  56. for: nil
  57. )
  58. }
  59. }
  60. struct ContentView_Previews: PreviewProvider {
  61. static var previews: some View {
  62. ContentView()
  63. }
  64. }