1 |
efrain |
1 |
//
|
|
|
2 |
// NotificationListItemView.swift
|
|
|
3 |
// twogetskills
|
|
|
4 |
//
|
|
|
5 |
// Created by admin on 8/14/22.
|
|
|
6 |
//
|
|
|
7 |
|
|
|
8 |
import SwiftUI
|
|
|
9 |
|
|
|
10 |
struct NotificationListItemView: View {
|
|
|
11 |
|
|
|
12 |
var notification : UserNotificationModel
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
let onExecute: () -> Void
|
|
|
16 |
let onDelete: () -> Void
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
|
|
|
21 |
var body: some View {
|
|
|
22 |
VStack(spacing: 0 ) {
|
|
|
23 |
Group {
|
|
|
24 |
HStack {
|
|
|
25 |
|
|
|
26 |
VStack(spacing: 0)
|
|
|
27 |
{
|
|
|
28 |
HStack {
|
|
|
29 |
Text(notification.title)
|
|
|
30 |
.font(Font.custom(Config.FONT_NAME_BOLD, size: 16))
|
|
|
31 |
.foregroundColor(Color("color_capsule_list_item_title_foreground"))
|
|
|
32 |
|
|
|
33 |
Spacer()
|
|
|
34 |
|
|
|
35 |
|
|
|
36 |
if !notification.command.isEmpty && notification.viewed == 0 {
|
|
|
37 |
|
|
|
38 |
Button(action: onExecute, label: {
|
|
|
39 |
Image(systemName: "arrowtriangle.right.fill")
|
|
|
40 |
.resizable()
|
|
|
41 |
.aspectRatio(contentMode: /*@START_MENU_TOKEN@*/.fill/*@END_MENU_TOKEN@*/)
|
|
|
42 |
.frame(width: 16, height: 16, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
|
|
|
43 |
}).padding(.trailing, 10)
|
|
|
44 |
.foregroundColor(Color("color_capsule_list_item_title_foreground"))
|
|
|
45 |
|
|
|
46 |
} else {
|
|
|
47 |
|
|
|
48 |
|
|
|
49 |
Button(action: onDelete, label: {
|
|
|
50 |
Image(systemName: "trash")
|
|
|
51 |
.resizable()
|
|
|
52 |
.aspectRatio(contentMode: /*@START_MENU_TOKEN@*/.fill/*@END_MENU_TOKEN@*/)
|
|
|
53 |
.frame(width: 16, height: 16, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
|
|
|
54 |
}).padding(.trailing, 10)
|
|
|
55 |
.foregroundColor(Color("color_capsule_list_item_title_foreground"))
|
|
|
56 |
}
|
|
|
57 |
|
|
|
58 |
}
|
|
|
59 |
HStack {
|
|
|
60 |
Text(notification.body)
|
|
|
61 |
.font(Font.custom(Config.FONT_NAME_REGULAR, size: 12))
|
|
|
62 |
.foregroundColor(Color("color_capsule_list_item_description_foreground"))
|
|
|
63 |
|
|
|
64 |
|
|
|
65 |
Spacer()
|
|
|
66 |
}.padding(.top, 3)
|
|
|
67 |
.padding(.bottom, 10)
|
|
|
68 |
|
|
|
69 |
|
|
|
70 |
HStack {
|
|
|
71 |
|
|
|
72 |
|
|
|
73 |
Spacer()
|
|
|
74 |
|
|
|
75 |
Text(notification.timeOn)
|
|
|
76 |
.font(Font.custom(Config.FONT_NAME_REGULAR, size: 12))
|
|
|
77 |
.foregroundColor(Color("color_capsule_list_item_description_foreground"))
|
|
|
78 |
.padding(.trailing, 10)
|
|
|
79 |
|
|
|
80 |
|
|
|
81 |
|
|
|
82 |
|
|
|
83 |
}.padding(.top, 5)
|
|
|
84 |
.padding(.bottom, 10)
|
|
|
85 |
|
|
|
86 |
|
|
|
87 |
|
|
|
88 |
|
|
|
89 |
}.padding(.top, 10)
|
|
|
90 |
.padding(.bottom, 10)
|
|
|
91 |
|
|
|
92 |
}
|
|
|
93 |
|
|
|
94 |
|
|
|
95 |
Divider()
|
|
|
96 |
} .background(Color("color_capsule_list_item_background"))
|
|
|
97 |
.padding(.leading, 5)
|
|
|
98 |
.padding(.trailing, 5)
|
|
|
99 |
}
|
|
|
100 |
}
|
|
|
101 |
}
|
|
|
102 |
|
|
|
103 |
struct NotificationListItemView_Previews: PreviewProvider {
|
|
|
104 |
|
|
|
105 |
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")
|
|
|
106 |
|
|
|
107 |
static var previews: some View {
|
|
|
108 |
NotificationListItemView(notification: notification,onExecute: {}) {
|
|
|
109 |
|
|
|
110 |
}
|
|
|
111 |
}
|
|
|
112 |
}
|
|
|
113 |
|