Proyectos de Subversion Iphone Microlearning - Nuevo Interface

Rev

Rev 11 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |

//
//  CommentAndRatingView.swift
//  twogetskills
//
//  Created by Efrain Yanez Recanatini on 7/28/22.
//

import SwiftUI
import AudioToolbox

struct CommentAndRatingView: View {
    var introduction : String =  "<h1>Welcome to SwiftlyRush's bank</h1>, you will be able to access your <b>accounts</b> in this application"
    
    @State var comments : [CommentAndRatingComment] = [CommentAndRatingComment]()
    
    @State var isValidComment : Bool = true
    
    
    @State var comment : String = "Welcome to SwiftlyRush's bank, you will be able to access your accounts in this application" {
        didSet {
            if comment.count > 128 {
                comment =  String(comment.prefix(128))
                AudioServicesPlayAlertSoundWithCompletion(SystemSoundID(kSystemSoundID_Vibrate)) { return }
            }
        }
    }
    
    
    @State private var selectedType: CommentAndRatingPickerType = .introduction
    
    var body: some View {
        

        
        VStack(spacing: 0)
        {
            HStack {
                Image("logo")
                .resizable()
                .frame(width: 32, height: 32, alignment: .center)
                .aspectRatio(contentMode: .fit)
                .foregroundColor(Color("color_app_bar_foreground"))
                .padding(.leading, 16)
             
                
                Text(Config.LANG_TAB_BAR_BUTTON_TOPICS)
                .font(Font.custom(Config.FONT_NAME_REGULAR, size: Config.FONT_SIZE_APP_BAR_HEAD1 ))
                .foregroundColor(Color("color_app_bar_foreground"))
                .padding(.leading, 4)
                
                Spacer()
                
            }
            .background(Color("color_app_bar_background"))
            .edgesIgnoringSafeArea(.top)
            .frame(height: 50)
            
            Divider()
            
            
            CommentAndRatingImageView()
            
            CommentAndRatingPickerView(selectedType: self.$selectedType).frame(height: 48)
            
             switch self.selectedType
             {
                case .introduction :
                    CommentAndRatingIntroductionView(introduction: introduction)
                
                case .comments :
                    CommentAndRatingCommentListView(comments: self.comments)
          
                default :
                    CommentAndRatingPostCommentView(comment: self.$comment)
            }
            
            Spacer()
        }            .background(Color("color_picker_background"))
    }
}

struct CommentAndRatingView_Previews: PreviewProvider {
    static var previews: some View {
        CommentAndRatingView()
    }
}