Skip to content

Commit 0295d44

Browse files
authored
Update notification-toaster.yaml
Updated version with component advanced properties
1 parent 5af0b33 commit 0295d44

File tree

1 file changed

+52
-14
lines changed

1 file changed

+52
-14
lines changed

power-apps/Notification-Toaster/source/notification-toaster.yaml

Lines changed: 52 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,31 @@ ComponentDefinitions:
88
DisplayName: AutoHeight
99
Description: A custom property
1010
DataType: Number
11+
Notify:
12+
PropertyKind: Action
13+
DisplayName: Notify
14+
Description: A custom property
15+
ReturnType: Table
16+
Parameters:
17+
- Title:
18+
Description: Notification title (bold)
19+
DataType: Text
20+
Default: =""
21+
- Type:
22+
Description: Notification type, use NotificationType.Succes .Error etc..
23+
IsOptional: true
24+
DataType: Number
25+
Default: =3
26+
- Text:
27+
Description: Detailled notification text
28+
IsOptional: true
29+
DataType: Text
30+
Default: =""
31+
- Duration:
32+
Description: Notification duration in milliseconds
33+
IsOptional: true
34+
DataType: Number
35+
Default: =Blank()
1136
Theme:
1237
PropertyKind: Input
1338
DisplayName: Theme
@@ -16,20 +41,21 @@ ComponentDefinitions:
1641
Default: |-
1742
=/*---------------- Instructions ------------------
1843
To Notify, use :
19-
Collect(colNotifications, {
20-
Title: "✅ Success", // set your notificaiton title here
21-
Text: "Your settings have been saved successfully.", // put you notification text here
22-
Type: NotificationType.Success, // used for notification appearance
23-
Duration: 2000 // Notification duration in milliseconds
24-
}
25-
)
44+
45+
NotificationToaster_1.Notify( //replace 'NotificationToaster_1' by the name of the component in your app screen
46+
"✅ Success", // Mandatory : Title of your notification in bold text
47+
NotificationType.Success, // Optionnal : NotificationType.Information by default
48+
"Your settings have been saved successfully.", // Optional : Detailled notifiction text
49+
3000 // Optionnal : The notification lifetime will be calculated based on the number of characters to be read and the 'ReadingSpeed' in the 'Theme' parameter
50+
2651
Componnent positionning : To position the component in the bottom right corner of your screen, use the following positioning formulas:
2752
x: Parent.Width-Self.Width
2853
y: Parent.Height-Self.Height
2954
3055
*/
3156
{Transparency:"99", // in hexadecimal : from 00(transparent) to ff (opaque)
3257
FontSize:11,
58+
ReadingSpeed:23, // chars per second, used to calculate default notification duration
3359
SuccessTextColor:"#ffffff",
3460
SuccessBckgndColor:"#009944",
3561
ErrorTextColor:"#ffffff",
@@ -45,7 +71,8 @@ ComponentDefinitions:
4571
Height: |-
4672
=// Adjusts the height according to the number of notifications without exceeding the screen height, do not modify
4773
Min(NotificationToaster.AutoHeight,App.ActiveScreen.Height)
48-
Width: =640 // Can be adjusted
74+
Notify: =Collect(colNotifications,{ID:Max(colNotifications,ID)+1,Title:Title,Text:Text, Type:Type, Duration:Duration})
75+
Width: =420
4976
Children:
5077
- GalleryNotifs:
5178
Control: Gallery@2.15.0
@@ -75,7 +102,7 @@ ComponentDefinitions:
75102
/* --- Div styles --- */
76103
position: relative;
77104
overflow: hidden; /* Nécessaire pour couper la barre de progression aux bords arrondis */
78-
width: 98%;
105+
width: 100%;
79106
box-sizing: border-box;
80107
color: {Switch(ThisItem.Type,NotificationType.Error,NotificationToaster.Theme.ErrorTextColor,NotificationType.Information,NotificationToaster.Theme.InformationTextColor,NotificationType.Success,NotificationToaster.Theme.SuccessTextColor,NotificationType.Warning,NotificationToaster.Theme.WarningTextColor,"#000000")};
81108
border-radius: 16px;
@@ -84,6 +111,7 @@ ComponentDefinitions:
84111
margin-bottom: 5px;
85112
padding: 20px;
86113
padding-top: 25px;
114+
padding-right: 35px;
87115
backdrop-filter: blur(8px);
88116
-webkit-backdrop-filter: blur(8px);
89117
@@ -99,7 +127,7 @@ ComponentDefinitions:
99127
width: 100%;
100128
height: 4px;
101129
background-color: rgba(255, 255, 255, 0.3);
102-
'>{If((ThisItem.ID=First(colNotifications).ID && ThisItem.ID <> Blank()) || CountRows(colNotifications)=1 /* Hide progress bar if not first item */,$"
130+
'>{If(ThisItem.ID=First(colNotifications).ID /* Show progress bar only on 1st item */,$"
103131
<div class='progress-bar-fill' style='
104132
height: 100%;
105133
width: {Text(IfError(TimerDeleteNotification.Value*100/TimerDeleteNotification.Duration,0),"0.00","en-US")}%; /* Force en-US to avoid comma separated decimals */
@@ -137,18 +165,28 @@ ComponentDefinitions:
137165
Icon: ="DismissCircle"
138166
IconStyle: ='ButtonCanvas.IconStyle'.Filled
139167
Layout: ='ButtonCanvas.Layout'.IconOnly
140-
OnSelect: =If(ThisItem.ID=First(colNotifications).ID && ThisItem.ID <> Blank(), Set(vRemoveNotif,TimerDeleteNotification.Value) ,Remove(colNotifications,ThisItem))
168+
OnSelect: |-
169+
=If(ThisItem.ID=First(colNotifications).ID && ThisItem.ID <> Blank() // To avoid timer from keeping last item value
170+
, Set(vRemoveNotif,TimerDeleteNotification.Value) ,Remove(colNotifications,ThisItem))
141171
Text: ="Remove"
142172
Width: =40
143-
X: =Parent.TemplateWidth-Self.Width-25
173+
X: =Parent.TemplateWidth-Self.Width-15
144174
Y: =15
145175
- TimerDeleteNotification:
146176
Control: Timer@2.1.0
147177
Properties:
148178
AutoStart: =true
149-
Duration: =Coalesce(vRemoveNotif,First(colNotifications).Duration,2000)
179+
Duration: |-
180+
=With({FirstNotif:First(colNotifications)},
181+
Coalesce(
182+
vRemoveNotif,
183+
FirstNotif.Duration,
184+
IfError((Len(FirstNotif.Title)+Len(FirstNotif.Text))/NotificationToaster.Theme.ReadingSpeed*1000,3500))
185+
)
150186
OnSelect: =Collect(colNotifications,FirstN([{ID:1,Title:"",Text:"",Duration:1000}],0))
151-
OnTimerEnd: =UpdateIf(colNotifications,ID=Blank(),{ID:Max(colNotifications,ID)+1});Remove(colNotifications,First(colNotifications));Set(vRemoveNotif,Blank())
187+
OnTimerEnd: |-
188+
=Remove(colNotifications,First(colNotifications));
189+
Set(vRemoveNotif,Blank()) // To avoid timer from keeping last item value
152190
OnTimerStart: =UpdateIf(colNotifications,ID=Blank(),{ID:Max(colNotifications,ID)+1})
153191
Repeat: =true
154192
Reset: =//CountIf(colNotifications,ID=Blank())>0 || CountIf(colNotifications,ID=Blank())=0

0 commit comments

Comments
 (0)