TSKeyboardView.swift 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. //
  2. // TSKeyboardView.swift
  3. // AIEmoji
  4. //
  5. // Created by 100Years on 2025/1/21.
  6. //
  7. import SwiftUI
  8. import Combine
  9. struct TSKeyboardView : View {
  10. var keyBoardModelArray:[[DiyStickerModel]]
  11. let clickKeyPublisher:PassthroughSubject<DiyStickerModel, Never>
  12. var body: some View {
  13. let itemW = (k_ScreenWidth - 56)/10.0
  14. return VStack {
  15. Spacer().frame(height: 12)
  16. VStack(spacing:12) {
  17. ForEach(keyBoardModelArray, id: \.self) { array in
  18. HStack(spacing:5) {
  19. ForEach(array, id: \.self.name) { model in
  20. if model.name == kKeyDelete {
  21. TSKeyboardDeleteView(model: model).frame(width:itemW)
  22. .onTapGesture {
  23. clickKeyPublisher.send(model)
  24. }
  25. }else{
  26. TSKeyboardItemView(model: model).frame(width:itemW)
  27. .onTapGesture {
  28. clickKeyPublisher.send(model)
  29. }
  30. }
  31. }
  32. }
  33. }
  34. }
  35. Spacer().frame(height: 8 + k_Height_safeAreaInsetsBottom())
  36. }
  37. }
  38. }
  39. struct TSKeyboardItemView : View {
  40. var model:DiyStickerModel
  41. var body: some View {
  42. return VStack {
  43. VStack(spacing: 0) {
  44. Spacer().frame(height: 4)
  45. Image(model.imageUrl ?? "").resizable().frame(width: 24, height: 24)
  46. HStack {
  47. Spacer()
  48. Text(model.name ?? "?").foregroundColor(.black).font(.font(size: 12)).frame(height: 12)
  49. Spacer().frame(width: 2)
  50. }
  51. Spacer().frame(height: 2)
  52. }
  53. .background("#F1F4F8".uiColor.color)
  54. .cornerRadius(5)
  55. .shadow(color: .black.opacity(0.2), radius: 2, x: 0, y: 2) // 设置阴影
  56. }
  57. }
  58. }
  59. struct TSKeyboardDeleteView : View {
  60. var model:DiyStickerModel
  61. var body: some View {
  62. return HStack {
  63. Spacer().frame(width: 14).background(Color.red)
  64. VStack {
  65. Image(model.imageUrl ?? "").resizable().frame(width: 23, height: 17)
  66. }
  67. .frame(width: 42,height: 42)
  68. .background("#F1F4F8".uiColor.color)
  69. .cornerRadius(5)
  70. .shadow(color: .black.opacity(0.2), radius: 2, x: 0, y: 2) // 设置阴影
  71. }
  72. }
  73. }