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
12 changes: 8 additions & 4 deletions examples/demo-fm/lib/models/in_app_message_type.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
enum InAppMessageType {
topBanner('Top Banner', 'top_banner'),
bottomBanner('Bottom Banner', 'bottom_banner'),
centerModal('Center Modal', 'center_modal'),
fullScreen('Full Screen', 'full_screen');
topBanner('Top', 'top_banner'),
bottomBanner('Bottom', 'bottom_banner'),
centerModal('Center', 'center_modal'),
html('HTML', 'html'),
fullScreen('Full', 'full_screen'),
fullBleed('Full Bleed', 'full_bleed'),
carousel('Carousel', 'carousel'),
carouselBleed('Carousel Bleed', 'carousel_bleed');

final String label;
final String triggerValue;
Expand Down
22 changes: 14 additions & 8 deletions examples/demo-fm/lib/widgets/action_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ class PrimaryButton extends StatelessWidget {
final VoidCallback? onPressed;
final IconData? icon;
final String? semanticsLabel;
final EdgeInsetsGeometry? padding;

const PrimaryButton({
super.key,
required this.label,
this.onPressed,
this.icon,
this.semanticsLabel,
this.padding,
});

@override
Expand All @@ -25,16 +27,20 @@ class PrimaryButton extends StatelessWidget {
style: ElevatedButton.styleFrom(
backgroundColor: AppColors.osPrimary,
foregroundColor: Colors.white,
padding: padding,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (icon != null) ...[
Icon(icon, size: 18),
const SizedBox(width: 8),
child: FittedBox(
fit: BoxFit.scaleDown,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
if (icon != null) ...[
Icon(icon, size: 18),
const SizedBox(width: 8),
],
Text(label),
],
Text(label),
],
),
),
),
);
Expand Down
24 changes: 17 additions & 7 deletions examples/demo-fm/lib/widgets/sections/send_iam_section.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,30 @@ class SendIamSection extends StatelessWidget {
@override
Widget build(BuildContext context) {
final vm = context.read<AppViewModel>();
const types = InAppMessageType.values;

return SectionCard(
title: 'Send In-App Message',
sectionKey: 'send_iam',
onInfoTap: onInfoTap,
child: Column(
spacing: AppSpacing.gap,
children: InAppMessageType.values.map((type) {
return PrimaryButton(
label: type.label.toUpperCase(),
onPressed: () => vm.sendInAppMessage(type),
semanticsLabel: 'send_iam_${type.triggerValue}_button',
);
}).toList(),
children: [
for (var i = 0; i < types.length; i += 2)
Row(
spacing: AppSpacing.gap,
children: types.sublist(i, i + 2).map((type) {
return Expanded(
child: PrimaryButton(
label: type.label.toUpperCase(),
onPressed: () => vm.sendInAppMessage(type),
semanticsLabel: 'send_iam_${type.triggerValue}_button',
padding: const EdgeInsets.symmetric(horizontal: 8),
),
);
}).toList(),
),
],
),
);
}
Expand Down
17 changes: 9 additions & 8 deletions examples/demo-pods/lib/models/in_app_message_type.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import 'package:flutter/material.dart';

enum InAppMessageType {
topBanner('Top Banner', 'top_banner', Icons.vertical_align_top),
bottomBanner('Bottom Banner', 'bottom_banner', Icons.vertical_align_bottom),
centerModal('Center Modal', 'center_modal', Icons.crop_square),
fullScreen('Full Screen', 'full_screen', Icons.fullscreen);
topBanner('Top', 'top_banner'),
bottomBanner('Bottom', 'bottom_banner'),
centerModal('Center', 'center_modal'),
html('HTML', 'html'),
fullScreen('Full', 'full_screen'),
fullBleed('Full Bleed', 'full_bleed'),
carousel('Carousel', 'carousel'),
carouselBleed('Carousel Bleed', 'carousel_bleed');

final String label;
final String triggerValue;
final IconData icon;

const InAppMessageType(this.label, this.triggerValue, this.icon);
const InAppMessageType(this.label, this.triggerValue);
}
22 changes: 14 additions & 8 deletions examples/demo-pods/lib/widgets/action_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ class PrimaryButton extends StatelessWidget {
final VoidCallback? onPressed;
final IconData? icon;
final String? semanticsLabel;
final EdgeInsetsGeometry? padding;

const PrimaryButton({
super.key,
required this.label,
this.onPressed,
this.icon,
this.semanticsLabel,
this.padding,
});

@override
Expand All @@ -25,16 +27,20 @@ class PrimaryButton extends StatelessWidget {
style: ElevatedButton.styleFrom(
backgroundColor: AppColors.osPrimary,
foregroundColor: Colors.white,
padding: padding,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (icon != null) ...[
Icon(icon, size: 18),
const SizedBox(width: 8),
child: FittedBox(
fit: BoxFit.scaleDown,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
if (icon != null) ...[
Icon(icon, size: 18),
const SizedBox(width: 8),
],
Text(label),
],
Text(label),
],
),
),
),
);
Expand Down
43 changes: 16 additions & 27 deletions examples/demo-pods/lib/widgets/sections/send_iam_section.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:provider/provider.dart';
import '../../models/in_app_message_type.dart';
import '../../theme.dart';
import '../../viewmodels/app_viewmodel.dart';
import '../action_button.dart';
import '../section_card.dart';

class SendIamSection extends StatelessWidget {
Expand All @@ -14,42 +15,30 @@ class SendIamSection extends StatelessWidget {
@override
Widget build(BuildContext context) {
final vm = context.read<AppViewModel>();
const types = InAppMessageType.values;

return SectionCard(
title: 'Send In-App Message',
sectionKey: 'send_iam',
onInfoTap: onInfoTap,
child: Column(
spacing: AppSpacing.gap,
children: InAppMessageType.values.map((type) {
return Semantics(
identifier: 'send_iam_${type.triggerValue}_button',
container: true,
button: true,
child: SizedBox(
width: double.infinity,
child: ElevatedButton(
onPressed: () => vm.sendInAppMessage(type),
style: ElevatedButton.styleFrom(
backgroundColor: AppColors.osPrimary,
foregroundColor: Colors.white,
minimumSize: const Size(double.infinity, 48),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
children: [
for (var i = 0; i < types.length; i += 2)
Row(
spacing: AppSpacing.gap,
children: types.sublist(i, i + 2).map((type) {
return Expanded(
child: PrimaryButton(
label: type.label.toUpperCase(),
onPressed: () => vm.sendInAppMessage(type),
semanticsLabel: 'send_iam_${type.triggerValue}_button',
padding: const EdgeInsets.symmetric(horizontal: 8),
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Icon(type.icon, size: 18),
const SizedBox(width: 8),
Text(type.label.toUpperCase()),
],
),
),
);
}).toList(),
),
);
}).toList(),
],
),
);
}
Expand Down
12 changes: 8 additions & 4 deletions examples/demo/lib/models/in_app_message_type.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
enum InAppMessageType {
topBanner('Top Banner', 'top_banner'),
bottomBanner('Bottom Banner', 'bottom_banner'),
centerModal('Center Modal', 'center_modal'),
fullScreen('Full Screen', 'full_screen');
topBanner('Top', 'top_banner'),
bottomBanner('Bottom', 'bottom_banner'),
centerModal('Center', 'center_modal'),
html('HTML', 'html'),
fullScreen('Full', 'full_screen'),
fullBleed('Full Bleed', 'full_bleed'),
carousel('Carousel', 'carousel'),
carouselBleed('Carousel Bleed', 'carousel_bleed');

final String label;
final String triggerValue;
Expand Down
22 changes: 14 additions & 8 deletions examples/demo/lib/widgets/action_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ class PrimaryButton extends StatelessWidget {
final VoidCallback? onPressed;
final IconData? icon;
final String? semanticsLabel;
final EdgeInsetsGeometry? padding;

const PrimaryButton({
super.key,
required this.label,
this.onPressed,
this.icon,
this.semanticsLabel,
this.padding,
});

@override
Expand All @@ -25,16 +27,20 @@ class PrimaryButton extends StatelessWidget {
style: ElevatedButton.styleFrom(
backgroundColor: AppColors.osPrimary,
foregroundColor: Colors.white,
padding: padding,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (icon != null) ...[
Icon(icon, size: 18),
const SizedBox(width: 8),
child: FittedBox(
fit: BoxFit.scaleDown,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
if (icon != null) ...[
Icon(icon, size: 18),
const SizedBox(width: 8),
],
Text(label),
],
Text(label),
],
),
),
),
);
Expand Down
24 changes: 17 additions & 7 deletions examples/demo/lib/widgets/sections/send_iam_section.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,30 @@ class SendIamSection extends StatelessWidget {
@override
Widget build(BuildContext context) {
final vm = context.read<AppViewModel>();
const types = InAppMessageType.values;

return SectionCard(
title: 'Send In-App Message',
sectionKey: 'send_iam',
onInfoTap: onInfoTap,
child: Column(
spacing: AppSpacing.gap,
children: InAppMessageType.values.map((type) {
return PrimaryButton(
label: type.label.toUpperCase(),
onPressed: () => vm.sendInAppMessage(type),
semanticsLabel: 'send_iam_${type.triggerValue}_button',
);
}).toList(),
children: [
for (var i = 0; i < types.length; i += 2)
Row(
spacing: AppSpacing.gap,
children: types.sublist(i, i + 2).map((type) {
return Expanded(
child: PrimaryButton(
label: type.label.toUpperCase(),
onPressed: () => vm.sendInAppMessage(type),
semanticsLabel: 'send_iam_${type.triggerValue}_button',
padding: const EdgeInsets.symmetric(horizontal: 8),
),
);
}).toList(),
),
],
),
);
}
Expand Down
Loading