| 1 |
efrain |
1 |
//
|
|
|
2 |
// CommentAndRatingView.swift
|
|
|
3 |
// twogetskills
|
|
|
4 |
//
|
|
|
5 |
// Created by Efrain Yanez Recanatini on 7/28/22.
|
|
|
6 |
//
|
|
|
7 |
|
|
|
8 |
import SwiftUI
|
|
|
9 |
import AudioToolbox
|
|
|
10 |
|
|
|
11 |
struct CommentAndRatingView: View {
|
|
|
12 |
var introduction : String = "<h1>Welcome to SwiftlyRush's bank</h1>, you will be able to access your <b>accounts</b> in this application"
|
|
|
13 |
|
|
|
14 |
@State var comments : [CommentAndRatingComment] = [CommentAndRatingComment]()
|
|
|
15 |
|
|
|
16 |
@State var isValidComment : Bool = true
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
@State var comment : String = "Welcome to SwiftlyRush's bank, you will be able to access your accounts in this application" {
|
|
|
20 |
didSet {
|
|
|
21 |
if comment.count > 128 {
|
|
|
22 |
comment = String(comment.prefix(128))
|
|
|
23 |
AudioServicesPlayAlertSoundWithCompletion(SystemSoundID(kSystemSoundID_Vibrate)) { return }
|
|
|
24 |
}
|
|
|
25 |
}
|
|
|
26 |
}
|
|
|
27 |
|
|
|
28 |
|
|
|
29 |
@State private var selectedType: CommentAndRatingPickerType = .introduction
|
|
|
30 |
|
|
|
31 |
var body: some View {
|
|
|
32 |
|
|
|
33 |
|
|
|
34 |
|
|
|
35 |
VStack(spacing: 0)
|
|
|
36 |
{
|
|
|
37 |
HStack {
|
|
|
38 |
Image("logo")
|
|
|
39 |
.resizable()
|
|
|
40 |
.frame(width: 32, height: 32, alignment: .center)
|
|
|
41 |
.aspectRatio(contentMode: .fit)
|
|
|
42 |
.foregroundColor(Color("color_app_bar_foreground"))
|
|
|
43 |
.padding(.leading, 16)
|
|
|
44 |
|
|
|
45 |
|
|
|
46 |
Text(Config.LANG_TAB_BAR_BUTTON_TOPICS)
|
|
|
47 |
.font(Font.custom(Config.FONT_NAME_REGULAR, size: Config.FONT_SIZE_APP_BAR_HEAD1 ))
|
|
|
48 |
.foregroundColor(Color("color_app_bar_foreground"))
|
|
|
49 |
.padding(.leading, 4)
|
|
|
50 |
|
|
|
51 |
Spacer()
|
|
|
52 |
|
|
|
53 |
}
|
|
|
54 |
.background(Color("color_app_bar_background"))
|
|
|
55 |
.edgesIgnoringSafeArea(.top)
|
|
|
56 |
.frame(height: 50)
|
|
|
57 |
|
|
|
58 |
Divider()
|
|
|
59 |
|
|
|
60 |
|
|
|
61 |
CommentAndRatingImageView()
|
|
|
62 |
|
|
|
63 |
CommentAndRatingPickerView(selectedType: self.$selectedType).frame(height: 48)
|
|
|
64 |
|
|
|
65 |
switch self.selectedType
|
|
|
66 |
{
|
|
|
67 |
case .introduction :
|
|
|
68 |
CommentAndRatingIntroductionView(introduction: introduction)
|
|
|
69 |
|
|
|
70 |
case .comments :
|
|
|
71 |
CommentAndRatingCommentListView(comments: self.comments)
|
|
|
72 |
|
|
|
73 |
default :
|
|
|
74 |
CommentAndRatingPostCommentView(comment: self.$comment)
|
|
|
75 |
}
|
|
|
76 |
|
|
|
77 |
Spacer()
|
|
|
78 |
} .background(Color("color_picker_background"))
|
|
|
79 |
}
|
|
|
80 |
}
|
|
|
81 |
|
|
|
82 |
struct CommentAndRatingView_Previews: PreviewProvider {
|
|
|
83 |
static var previews: some View {
|
|
|
84 |
CommentAndRatingView()
|
|
|
85 |
}
|
|
|
86 |
}
|
|
|
87 |
|
|
|
88 |
|