@@ -7,6 +7,18 @@ namespace OneSignalDemo.UI.Sections
77{
88 public class SendIamSectionController
99 {
10+ private static readonly InAppMessageType [ ] Types =
11+ {
12+ InAppMessageType . TopBanner ,
13+ InAppMessageType . BottomBanner ,
14+ InAppMessageType . CenterModal ,
15+ InAppMessageType . Html ,
16+ InAppMessageType . FullScreen ,
17+ InAppMessageType . FullBleed ,
18+ InAppMessageType . Carousel ,
19+ InAppMessageType . CarouselBleed ,
20+ } ;
21+
1022 private readonly AppViewModel _viewModel ;
1123 private readonly VisualElement _root ;
1224
@@ -28,34 +40,28 @@ private VisualElement BuildSection()
2840 ( ) => OnInfoTap ? . Invoke ( )
2941 ) ;
3042
31- section . Add (
32- SectionBuilder . CreatePrimaryButton (
33- "TOP BANNER" ,
34- "send_iam_top_banner_button" ,
35- ( ) => _viewModel . SendInAppMessage ( InAppMessageType . TopBanner )
36- )
37- ) ;
38- section . Add (
39- SectionBuilder . CreatePrimaryButton (
40- "BOTTOM BANNER" ,
41- "send_iam_bottom_banner_button" ,
42- ( ) => _viewModel . SendInAppMessage ( InAppMessageType . BottomBanner )
43- )
44- ) ;
45- section . Add (
46- SectionBuilder . CreatePrimaryButton (
47- "CENTER MODAL" ,
48- "send_iam_center_modal_button" ,
49- ( ) => _viewModel . SendInAppMessage ( InAppMessageType . CenterModal )
50- )
51- ) ;
52- section . Add (
53- SectionBuilder . CreatePrimaryButton (
54- "FULL SCREEN" ,
55- "send_iam_full_screen_button" ,
56- ( ) => _viewModel . SendInAppMessage ( InAppMessageType . FullScreen )
57- )
58- ) ;
43+ VisualElement row = null ;
44+ for ( int i = 0 ; i < Types . Length ; i ++ )
45+ {
46+ if ( i % 2 == 0 )
47+ {
48+ row = new VisualElement ( ) ;
49+ row . AddToClassList ( "button-grid-row" ) ;
50+ section . Add ( row ) ;
51+ }
52+
53+ var type = Types [ i ] ;
54+ var btn = SectionBuilder . CreatePrimaryButton (
55+ type . DisplayName ( ) . ToUpperInvariant ( ) ,
56+ $ "send_iam_{ type . TriggerValue ( ) } _button",
57+ ( ) => _viewModel . SendInAppMessage ( type )
58+ ) ;
59+ btn . AddToClassList ( "button-grid-item" ) ;
60+ btn . AddToClassList (
61+ i % 2 == 0 ? "button-grid-item--leading" : "button-grid-item--trailing"
62+ ) ;
63+ row . Add ( btn ) ;
64+ }
5965
6066 return section ;
6167 }
0 commit comments