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. NavigationView {
  23. List{
  24. NavigationLink(destination: messageView(count:$messageCount)) {
  25. Text("消息")
  26. .badge(messageCount)
  27. }
  28. }
  29. .navigationBarTitle("数字校园")
  30. }
  31. .tabItem({Image(systemName: "graduationcap")
  32. Text("数字校园")})
  33. NavigationView{
  34. if isLoggedIn != 0{
  35. accountView(isLoggedIn: $isLoggedIn)
  36. .navigationBarTitle("账号")
  37. }
  38. else{
  39. loginView(isLoggedIn:$isLoggedIn)
  40. .navigationBarTitle("登录")
  41. }
  42. }
  43. .tabItem({Image(systemName: "person")
  44. Text("账号")})
  45. }
  46. }
  47. }
  48. extension View {
  49. func hideKeyboard() {
  50. UIApplication.shared.sendAction(
  51. #selector(UIResponder.resignFirstResponder),
  52. to: nil,
  53. from: nil,
  54. for: nil
  55. )
  56. }
  57. }
  58. struct ContentView_Previews: PreviewProvider {
  59. static var previews: some View {
  60. ContentView()
  61. }
  62. }