Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions examples/demo/Assets/Resources/Theme.uss
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,25 @@
color: #757575;
}

.button-grid-row {
flex-direction: row;
}

.button-grid-item {
flex-grow: 1;
flex-basis: 0;
padding: 0 8px;
white-space: nowrap;
}

.button-grid-item--leading {
margin-right: var(--card-gap);
}

.button-grid-item--trailing {
margin-left: 0;
}

.destructive-button {
background-color: transparent;
color: var(--os-primary);
Expand Down
22 changes: 17 additions & 5 deletions examples/demo/Assets/Scripts/Models/InAppMessageType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ public enum InAppMessageType
TopBanner,
BottomBanner,
CenterModal,
Html,
FullScreen,
FullBleed,
Carousel,
CarouselBleed,
}

public static class InAppMessageTypeExtensions
Expand All @@ -16,18 +20,26 @@ public static string TriggerValue(this InAppMessageType type) =>
InAppMessageType.TopBanner => "top_banner",
InAppMessageType.BottomBanner => "bottom_banner",
InAppMessageType.CenterModal => "center_modal",
InAppMessageType.Html => "html",
InAppMessageType.FullScreen => "full_screen",
InAppMessageType.FullBleed => "full_bleed",
InAppMessageType.Carousel => "carousel",
InAppMessageType.CarouselBleed => "carousel_bleed",
_ => "top_banner",
};

public static string DisplayName(this InAppMessageType type) =>
type switch
{
InAppMessageType.TopBanner => "Top Banner",
InAppMessageType.BottomBanner => "Bottom Banner",
InAppMessageType.CenterModal => "Center Modal",
InAppMessageType.FullScreen => "Full Screen",
_ => "Top Banner",
InAppMessageType.TopBanner => "Top",
InAppMessageType.BottomBanner => "Bottom",
InAppMessageType.CenterModal => "Center",
InAppMessageType.Html => "HTML",
InAppMessageType.FullScreen => "Full",
InAppMessageType.FullBleed => "Full Bleed",
InAppMessageType.Carousel => "Carousel",
InAppMessageType.CarouselBleed => "Carousel Bleed",
_ => "Top",
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ namespace OneSignalDemo.UI.Sections
{
public class SendIamSectionController
{
private static readonly InAppMessageType[] Types =
{
InAppMessageType.TopBanner,
InAppMessageType.BottomBanner,
InAppMessageType.CenterModal,
InAppMessageType.Html,
InAppMessageType.FullScreen,
InAppMessageType.FullBleed,
InAppMessageType.Carousel,
InAppMessageType.CarouselBleed,
};

private readonly AppViewModel _viewModel;
private readonly VisualElement _root;

Expand All @@ -28,34 +40,28 @@ private VisualElement BuildSection()
() => OnInfoTap?.Invoke()
);

section.Add(
SectionBuilder.CreatePrimaryButton(
"TOP BANNER",
"send_iam_top_banner_button",
() => _viewModel.SendInAppMessage(InAppMessageType.TopBanner)
)
);
section.Add(
SectionBuilder.CreatePrimaryButton(
"BOTTOM BANNER",
"send_iam_bottom_banner_button",
() => _viewModel.SendInAppMessage(InAppMessageType.BottomBanner)
)
);
section.Add(
SectionBuilder.CreatePrimaryButton(
"CENTER MODAL",
"send_iam_center_modal_button",
() => _viewModel.SendInAppMessage(InAppMessageType.CenterModal)
)
);
section.Add(
SectionBuilder.CreatePrimaryButton(
"FULL SCREEN",
"send_iam_full_screen_button",
() => _viewModel.SendInAppMessage(InAppMessageType.FullScreen)
)
);
VisualElement row = null;
for (int i = 0; i < Types.Length; i++)
{
if (i % 2 == 0)
{
row = new VisualElement();
row.AddToClassList("button-grid-row");
section.Add(row);
}

var type = Types[i];
var btn = SectionBuilder.CreatePrimaryButton(
type.DisplayName().ToUpperInvariant(),
$"send_iam_{type.TriggerValue()}_button",
() => _viewModel.SendInAppMessage(type)
);
btn.AddToClassList("button-grid-item");
btn.AddToClassList(
i % 2 == 0 ? "button-grid-item--leading" : "button-grid-item--trailing"
);
row.Add(btn);
}

return section;
}
Expand Down
Loading