MaterialSB/Example_Toast.sb
2026-01-24 21:36:45 +01:00

83 lines
2.2 KiB
Plaintext

; MaterialSB Example - Toast
; This example demonstrates the toast notification system
IncludeFile "MaterialSB.sbi"
EnableExplicit
Procedure ShowBasicToast()
MaterialSB::Toast("Hello! This is a simple toast.")
EndProcedure
Procedure ShowRoundedToast()
MaterialSB::Toast("This toast has rounded corners.", 4000, MaterialSB::#Toast_Rounded)
EndProcedure
Procedure ShowColoredToast()
MaterialSB::Toast("Success! Operation completed.", 4000, MaterialSB::#Toast_Default, MaterialSB::#Color_Green)
EndProcedure
Procedure ShowLongToast()
MaterialSB::Toast("This toast will stay visible for 8 seconds.", 8000)
EndProcedure
Procedure DismissAll()
MaterialSB::ToastDismissAll()
EndProcedure
Procedure Main(Result)
Protected t
UseModule MaterialSB
SetDarkTheme(#False)
; Navbar
Navbar(#Navbar_Shadow1 | #Navbar_Container)
NavbarAddLogo("Toasts")
Row(#Grid_Container)
Col(12)
Append("<h3>Toast Component</h3>")
Append("<p>Toasts provide brief messages about app processes at the bottom of the screen.</p>")
Append("<h5>Toast Examples</h5>")
Button("Basic Toast", @ShowBasicToast())
Button("Rounded Toast", @ShowRoundedToast(), #Button_Tonal)
Button("Colored Toast", @ShowColoredToast(), #Button_Outlined)
Button("Long Duration (8s)", @ShowLongToast(), #Button_Text)
AddClass(Button("Dismiss All", @DismissAll()), #Color_Red)
CloseCurrentParent()
Col(12)
Append("<br><br>")
Append("<h5>Toast Flags</h5>")
t = Table("Flag", #Table_Striped | #Table_Highlight)
TableAddColumn("Description", t)
TableAddItem("#Toast_Default" + Chr(10) + "Standard toast notification", t)
TableAddItem("#Toast_Rounded" + Chr(10) + "Toast with rounded corners", t)
Append("<br>")
Append("<h5>Usage</h5>")
Append(~"<pre>Toast(Text.s, Duration = 4000, Flags = #Toast_Default, Color.s = \"\")</pre>")
Append("<p>The Duration parameter specifies how long the toast is displayed in milliseconds.</p>")
CloseCurrentParent(2)
AutoInit()
UnuseModule MaterialSB
EndProcedure
MaterialSB::Download(@Main())
; IDE Options = SpiderBasic 3.10 (Windows - x86)
; CursorPosition = 7
; Folding = --
; iOSAppOrientation = 0
; AndroidAppCode = 0
; AndroidAppOrientation = 0
; EnableXP
; DPIAware
; CompileSourceDirectory