Proyectos de Subversion Iphone Microlearning - Inconcert

Rev

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

//
//  NotificationListItemView.swift
//  twogetskills
//
//  Created by admin on 8/14/22.
//

import SwiftUI

struct NotificationListItemView: View {
    
    var notification :  UserNotificationModel
    

    let onExecute: () -> Void
    let onDelete: () -> Void
    


    
    var body: some View {
        VStack(spacing: 0 ) {
        Group {
            HStack {
                
                VStack(spacing: 0)
                {
                    HStack {
                        Text(notification.title)
                            .font(Font.custom(Config.FONT_NAME_BOLD, size: 16))
                            .foregroundColor(Color("color_capsule_list_item_title_foreground"))
                     
                        Spacer()
                        
                        
                        if !notification.command.isEmpty && notification.viewed == 0 {
                            
                            Button(action:  onExecute, label: {
                                Image(systemName: "arrowtriangle.right.fill")
                                    .resizable()
                                    .aspectRatio(contentMode: /*@START_MENU_TOKEN@*/.fill/*@END_MENU_TOKEN@*/)
                                    .frame(width: 16, height: 16, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
                            }).padding(.trailing, 10)
                            .foregroundColor(Color("color_capsule_list_item_title_foreground"))
                            
                        } else {
                        
                        
                            Button(action:  onDelete, label: {
                                Image(systemName: "trash")
                                    .resizable()
                                    .aspectRatio(contentMode: /*@START_MENU_TOKEN@*/.fill/*@END_MENU_TOKEN@*/)
                                    .frame(width: 16, height: 16, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
                            }).padding(.trailing, 10)
                            .foregroundColor(Color("color_capsule_list_item_title_foreground"))
                        }
                        
                    }
                    HStack {
                        Text(notification.body)
                            .font(Font.custom(Config.FONT_NAME_REGULAR, size: 12))
                            .foregroundColor(Color("color_capsule_list_item_description_foreground"))
                     
                        
                        Spacer()
                    }.padding(.top, 3)
                    .padding(.bottom, 10)
                    
                    
                    HStack {

                        
                        Spacer()
                        
                        Text(notification.timeOn)
                            .font(Font.custom(Config.FONT_NAME_REGULAR, size: 12))
                            .foregroundColor(Color("color_capsule_list_item_description_foreground"))
                            .padding(.trailing, 10)
                        
                       
                    
                   
                    }.padding(.top, 5)
                .padding(.bottom, 10)
                
                
            
            
            }.padding(.top, 10)
            .padding(.bottom, 10)
            
        }
       
        
        Divider()
        } .background(Color("color_capsule_list_item_background"))
        .padding(.leading, 5)
        .padding(.trailing, 5)
        }
    }
}

struct NotificationListItemView_Previews: PreviewProvider {
    
    static var  notification  = UserNotificationModel( userUuid: "U123", title: "Titulo Notification #1", body: "Description Notification #1", viewed: 0, url: "https://www.google.co.ve", dateOn: "2022-08-12", timeOn: "10:00:00")
    
    static var previews: some View {
        NotificationListItemView(notification: notification,onExecute: {}) {
            
        }
    }
}