|
1 | 1 | using System; |
2 | 2 | using OneSignalDemo.Models; |
3 | | -using OneSignalDemo.Services; |
4 | | -using OneSignalDemo.UI; |
5 | 3 | using OneSignalDemo.ViewModels; |
6 | 4 | using UnityEngine.UIElements; |
7 | 5 |
|
@@ -31,63 +29,35 @@ private VisualElement BuildSection() |
31 | 29 | ); |
32 | 30 |
|
33 | 31 | section.Add( |
34 | | - CreateIamButton( |
| 32 | + SectionBuilder.CreatePrimaryButton( |
35 | 33 | "TOP BANNER", |
36 | | - MaterialIcons.VerticalAlignTop, |
37 | 34 | "send_iam_top_banner_button", |
38 | | - InAppMessageType.TopBanner |
| 35 | + () => _viewModel.SendInAppMessage(InAppMessageType.TopBanner) |
39 | 36 | ) |
40 | 37 | ); |
41 | 38 | section.Add( |
42 | | - CreateIamButton( |
| 39 | + SectionBuilder.CreatePrimaryButton( |
43 | 40 | "BOTTOM BANNER", |
44 | | - MaterialIcons.VerticalAlignBottom, |
45 | 41 | "send_iam_bottom_banner_button", |
46 | | - InAppMessageType.BottomBanner |
| 42 | + () => _viewModel.SendInAppMessage(InAppMessageType.BottomBanner) |
47 | 43 | ) |
48 | 44 | ); |
49 | 45 | section.Add( |
50 | | - CreateIamButton( |
| 46 | + SectionBuilder.CreatePrimaryButton( |
51 | 47 | "CENTER MODAL", |
52 | | - MaterialIcons.CropSquare, |
53 | 48 | "send_iam_center_modal_button", |
54 | | - InAppMessageType.CenterModal |
| 49 | + () => _viewModel.SendInAppMessage(InAppMessageType.CenterModal) |
55 | 50 | ) |
56 | 51 | ); |
57 | 52 | section.Add( |
58 | | - CreateIamButton( |
| 53 | + SectionBuilder.CreatePrimaryButton( |
59 | 54 | "FULL SCREEN", |
60 | | - MaterialIcons.Fullscreen, |
61 | 55 | "send_iam_full_screen_button", |
62 | | - InAppMessageType.FullScreen |
| 56 | + () => _viewModel.SendInAppMessage(InAppMessageType.FullScreen) |
63 | 57 | ) |
64 | 58 | ); |
65 | 59 |
|
66 | 60 | return section; |
67 | 61 | } |
68 | | - |
69 | | - private VisualElement CreateIamButton( |
70 | | - string text, |
71 | | - string icon, |
72 | | - string name, |
73 | | - InAppMessageType type |
74 | | - ) |
75 | | - { |
76 | | - void SendIam() => _viewModel.SendInAppMessage(type); |
77 | | - var btn = new Button(SendIam); |
78 | | - btn.name = name; |
79 | | - btn.AddToClassList("iam-button"); |
80 | | - AccessibilityBridge.RegisterE2ETapTarget(btn, () => btn.enabledInHierarchy, SendIam); |
81 | | - |
82 | | - var iconLabel = new Label(icon); |
83 | | - iconLabel.AddToClassList("iam-button-icon"); |
84 | | - btn.Add(iconLabel); |
85 | | - |
86 | | - var textLabel = new Label(text); |
87 | | - textLabel.AddToClassList("iam-button-label"); |
88 | | - btn.Add(textLabel); |
89 | | - |
90 | | - return btn; |
91 | | - } |
92 | 62 | } |
93 | 63 | } |
0 commit comments