diff --git a/examples/demo-fm/lib/models/in_app_message_type.dart b/examples/demo-fm/lib/models/in_app_message_type.dart index 983acddb..6aa707de 100644 --- a/examples/demo-fm/lib/models/in_app_message_type.dart +++ b/examples/demo-fm/lib/models/in_app_message_type.dart @@ -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; diff --git a/examples/demo-fm/lib/widgets/action_button.dart b/examples/demo-fm/lib/widgets/action_button.dart index 9222f81c..5bfdcaed 100644 --- a/examples/demo-fm/lib/widgets/action_button.dart +++ b/examples/demo-fm/lib/widgets/action_button.dart @@ -7,6 +7,7 @@ class PrimaryButton extends StatelessWidget { final VoidCallback? onPressed; final IconData? icon; final String? semanticsLabel; + final EdgeInsetsGeometry? padding; const PrimaryButton({ super.key, @@ -14,6 +15,7 @@ class PrimaryButton extends StatelessWidget { this.onPressed, this.icon, this.semanticsLabel, + this.padding, }); @override @@ -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), - ], + ), ), ), ); diff --git a/examples/demo-fm/lib/widgets/sections/send_iam_section.dart b/examples/demo-fm/lib/widgets/sections/send_iam_section.dart index 7830040e..29246e7d 100644 --- a/examples/demo-fm/lib/widgets/sections/send_iam_section.dart +++ b/examples/demo-fm/lib/widgets/sections/send_iam_section.dart @@ -15,6 +15,7 @@ class SendIamSection extends StatelessWidget { @override Widget build(BuildContext context) { final vm = context.read(); + const types = InAppMessageType.values; return SectionCard( title: 'Send In-App Message', @@ -22,13 +23,22 @@ class SendIamSection extends StatelessWidget { 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(), + ), + ], ), ); } diff --git a/examples/demo-pods/lib/models/in_app_message_type.dart b/examples/demo-pods/lib/models/in_app_message_type.dart index 01b6f721..6aa707de 100644 --- a/examples/demo-pods/lib/models/in_app_message_type.dart +++ b/examples/demo-pods/lib/models/in_app_message_type.dart @@ -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); } diff --git a/examples/demo-pods/lib/widgets/action_button.dart b/examples/demo-pods/lib/widgets/action_button.dart index 9222f81c..5bfdcaed 100644 --- a/examples/demo-pods/lib/widgets/action_button.dart +++ b/examples/demo-pods/lib/widgets/action_button.dart @@ -7,6 +7,7 @@ class PrimaryButton extends StatelessWidget { final VoidCallback? onPressed; final IconData? icon; final String? semanticsLabel; + final EdgeInsetsGeometry? padding; const PrimaryButton({ super.key, @@ -14,6 +15,7 @@ class PrimaryButton extends StatelessWidget { this.onPressed, this.icon, this.semanticsLabel, + this.padding, }); @override @@ -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), - ], + ), ), ), ); diff --git a/examples/demo-pods/lib/widgets/sections/send_iam_section.dart b/examples/demo-pods/lib/widgets/sections/send_iam_section.dart index 91edb94b..29246e7d 100644 --- a/examples/demo-pods/lib/widgets/sections/send_iam_section.dart +++ b/examples/demo-pods/lib/widgets/sections/send_iam_section.dart @@ -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 { @@ -14,6 +15,7 @@ class SendIamSection extends StatelessWidget { @override Widget build(BuildContext context) { final vm = context.read(); + const types = InAppMessageType.values; return SectionCard( title: 'Send In-App Message', @@ -21,35 +23,22 @@ class SendIamSection extends StatelessWidget { 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(), + ], ), ); } diff --git a/examples/demo/lib/models/in_app_message_type.dart b/examples/demo/lib/models/in_app_message_type.dart index 983acddb..6aa707de 100644 --- a/examples/demo/lib/models/in_app_message_type.dart +++ b/examples/demo/lib/models/in_app_message_type.dart @@ -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; diff --git a/examples/demo/lib/widgets/action_button.dart b/examples/demo/lib/widgets/action_button.dart index 9222f81c..5bfdcaed 100644 --- a/examples/demo/lib/widgets/action_button.dart +++ b/examples/demo/lib/widgets/action_button.dart @@ -7,6 +7,7 @@ class PrimaryButton extends StatelessWidget { final VoidCallback? onPressed; final IconData? icon; final String? semanticsLabel; + final EdgeInsetsGeometry? padding; const PrimaryButton({ super.key, @@ -14,6 +15,7 @@ class PrimaryButton extends StatelessWidget { this.onPressed, this.icon, this.semanticsLabel, + this.padding, }); @override @@ -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), - ], + ), ), ), ); diff --git a/examples/demo/lib/widgets/sections/send_iam_section.dart b/examples/demo/lib/widgets/sections/send_iam_section.dart index 7830040e..29246e7d 100644 --- a/examples/demo/lib/widgets/sections/send_iam_section.dart +++ b/examples/demo/lib/widgets/sections/send_iam_section.dart @@ -15,6 +15,7 @@ class SendIamSection extends StatelessWidget { @override Widget build(BuildContext context) { final vm = context.read(); + const types = InAppMessageType.values; return SectionCard( title: 'Send In-App Message', @@ -22,13 +23,22 @@ class SendIamSection extends StatelessWidget { 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(), + ), + ], ), ); }