TSSetingListView.swift 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. //
  2. // SettingListView.swift
  3. // AIEmoji
  4. //
  5. // Created by 100Years on 2025/1/16.
  6. //
  7. import SwiftUI
  8. import SwiftUIX
  9. struct TSSettingListView: View {
  10. @ObservedObject var viewModel: TSSetingViewModel
  11. var publisher: ListEventPublisher
  12. var body: some View {
  13. let spaceHeight = 16.0
  14. CocoaScrollView {
  15. VStack(spacing: 0) {
  16. Spacer().frame(height: spaceHeight)
  17. SettingPurchaseTopView(eventPublisher: publisher, vipType: $viewModel.vipType)
  18. .onTapGesture {
  19. publisher.enterPurchasePublisher.send(true)
  20. }
  21. if kPurchaseDefault.isVip {
  22. Spacer().frame(height: spaceHeight)
  23. SettingListVideoItemView(type: .videoPackage, publisher: publisher)
  24. }
  25. Spacer().frame(height: spaceHeight)
  26. VStack(spacing:0) {
  27. SettingListItemView(type: .videoTimes, publisher: publisher, rightView: SettingListNumItemView(num: $viewModel.videoTimes), rightArrow: false)
  28. SettingListItemView(type: .changeLanguage, publisher: publisher,rightView: EmptyView(), rightArrow: true)
  29. SettingListItemView(type: .update, publisher: publisher, rightView: SettingListAppUpdateItemView(isHaveNewVersion: $viewModel.isHaveNewVersion), rightArrow: true)
  30. }.cornerRadius(16)
  31. Spacer().frame(height: spaceHeight)
  32. VStack(spacing:0) {
  33. SettingListItemView(type: .rateus, publisher: publisher, rightView: EmptyView(), rightArrow: true)
  34. SettingListItemView(type: .shareus, publisher: publisher,rightView: EmptyView(), rightArrow: true)
  35. }.cornerRadius(16)
  36. Spacer().frame(height: spaceHeight)
  37. VStack(spacing:0) {
  38. SettingListItemView(type: .AboutData, publisher: publisher, rightView: EmptyView(), rightArrow: true)
  39. SettingListItemView(type: .removeCloudData, publisher: publisher,rightView: EmptyView(), rightArrow: true)
  40. SettingListItemView(type: .privacy, publisher: publisher,rightView: EmptyView(), rightArrow: true)
  41. SettingListItemView(type: .agreement, publisher: publisher,rightView: EmptyView(), rightArrow: true)
  42. }.cornerRadius(16)
  43. #if DEBUG
  44. Spacer().frame(height: spaceHeight)
  45. VStack(spacing:0) {
  46. SettingListItemView(type: .deleteAllData, publisher: publisher, rightView: EmptyView(), rightArrow: true)
  47. SettingListItemView(type: .lookAllData, publisher: publisher,rightView: EmptyView(), rightArrow: true)
  48. SettingListItemView(type: .videoTimesAdd, publisher: publisher,rightView: EmptyView(), rightArrow: true)
  49. SettingListItemView(type: .videoTimesReduce, publisher: publisher,rightView: EmptyView(), rightArrow: true)
  50. }.cornerRadius(16)
  51. #endif
  52. Spacer()
  53. }.padding(.horizontal)
  54. Spacer().frame(height: 20)
  55. }
  56. .alwaysBounceVertical(true)
  57. .scrollIndicatorStyle(HiddenScrollViewIndicatorStyle())
  58. }
  59. }
  60. struct SettingListItemView<RightView:View>: View {
  61. var type : SettingType
  62. var publisher: ListEventPublisher
  63. var rightView:RightView?
  64. var rightArrow: Bool
  65. var body: some View {
  66. ZStack {
  67. Color.white.opacity(0.1)
  68. HStack {
  69. Text(type.rawValue.localized).font(.font(size: 16.0)).foregroundColor(.white)
  70. Spacer()
  71. if let view = rightView{
  72. view
  73. }
  74. if rightArrow {
  75. Image(.whiteRightArrow)
  76. }
  77. }.padding(.horizontal)
  78. }
  79. .frame(height: 64)
  80. .onTapGesture {
  81. publisher.settingPublisher.send(type)
  82. }
  83. }
  84. }
  85. struct SettingListAppUpdateItemView: View {
  86. @Binding var isHaveNewVersion: Bool
  87. var body: some View {
  88. if isHaveNewVersion {
  89. Color.hex("#FECB34").frame(width: 4, height: 4).cornerRadius(2)
  90. Spacer().frame(width: 4)
  91. }
  92. Text(appVersion()).foregroundColor(.hex("#FFFFFF").opacity(0.4)).font(.font(size: 16))
  93. }
  94. }
  95. struct SettingListNumItemView: View {
  96. @Binding var num: Int
  97. var body: some View {
  98. Text("\(num)").foregroundColor(UIColor.themeColor.color).font(.font(size: 16))
  99. }
  100. }
  101. struct SettingListVideoItemView: View {
  102. var type : SettingType
  103. var publisher: ListEventPublisher
  104. var body: some View {
  105. ZStack{
  106. LinearGradient(gradient: Gradient(colors: [Color.hex("#583986"),Color.hex("#333C8C")]), startPoint: .leading, endPoint: .trailing)
  107. HStack(spacing:8){
  108. Image(.hourglass)
  109. Text("Video Effect Use Pack".localized).font(.font(size: 14.0)).foregroundColor(.white)
  110. Spacer()
  111. Image(.whiteRightArrow)
  112. }
  113. .padding(.horizontal)
  114. }
  115. .frame(height: 48)
  116. .cornerRadius(16)
  117. .onTapGesture {
  118. publisher.settingPublisher.send(type)
  119. }
  120. }
  121. }
  122. //
  123. //struct SettingListItemView: View {
  124. // var type : SettingType
  125. // var publisher: ListEventPublisher
  126. // @Binding var isHaveNewVersion: Bool
  127. //
  128. // var body: some View {
  129. // ZStack {
  130. // Color.white.opacity(0.1)
  131. // HStack {
  132. // Text(type.rawValue.localized).font(.font(size: 16.0)).foregroundColor(.white)
  133. // Spacer()
  134. // if type == .update {
  135. // if isHaveNewVersion {
  136. // Color.hex("#FECB34").frame(width: 4, height: 4).cornerRadius(2)
  137. // Spacer().frame(width: 4)
  138. // }
  139. // Text(appVersion()).foregroundColor(.hex("#FFFFFF").opacity(0.4)).font(.font(size: 16))
  140. // }
  141. //
  142. // Image(.whiteRightArrow)
  143. // }.padding(.horizontal)
  144. // }
  145. // .frame(height: 64)
  146. //// .cornerRadius(16)
  147. //// .cornerRadius(.allCorners, 16)
  148. // }
  149. //}