ChatListView.swift 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. //
  2. // ChatListView.swift
  3. // Chat
  4. //
  5. // Created by Sergey Tarasov on 24.07.2022.
  6. //
  7. import SwiftUI
  8. struct ChatListView: View {
  9. @Environment(\.colorScheme) var colorScheme
  10. var body: some View {
  11. List {
  12. ForEach(1..<14) { index in
  13. ZStack {
  14. HStack {
  15. Image(systemName: "person.crop.circle")
  16. .resizable()
  17. .scaledToFit()
  18. .foregroundColor(.secondary.opacity(0.5))
  19. .padding(.vertical, 8)
  20. VStack(alignment: .leading, spacing: 0) {
  21. HStack {
  22. Text("Андрей")
  23. Spacer()
  24. Text("23:04")
  25. .font(.callout)
  26. .foregroundColor(.secondary)
  27. }
  28. .padding(.vertical, 4)
  29. HStack {
  30. VStack {
  31. Text("Сообщение \(index)")
  32. .foregroundColor(.secondary)
  33. Spacer()
  34. }
  35. Spacer()
  36. Text("\(index)")
  37. .font(.callout)
  38. .foregroundColor(colorScheme == .light ? .white : .black)
  39. .padding(.horizontal, 6)
  40. .background(
  41. Capsule().foregroundColor(.secondary)
  42. )
  43. }
  44. .padding(.vertical, 6)
  45. }
  46. }
  47. .foregroundColor(.primary)
  48. .frame(height: 60)
  49. NavigationLink {
  50. ChatView()
  51. } label: {
  52. EmptyView()
  53. }
  54. .opacity(0.0)
  55. }
  56. }
  57. }
  58. .listStyle(.plain)
  59. .navigationTitle("Чаты")
  60. .navigationBarTitleDisplayMode(.inline)
  61. }
  62. }
  63. struct ChatListView_Previews: PreviewProvider {
  64. static var previews: some View {
  65. Group {
  66. NavigationView {
  67. ChatListView()
  68. }
  69. NavigationView {
  70. ChatListView()
  71. }
  72. .preferredColorScheme(.dark)
  73. }
  74. }
  75. }