diff --git a/firebase_ai_logic_showcase/lib/demos/chat_nano/chat_nano_demo.dart b/firebase_ai_logic_showcase/lib/demos/chat_nano/chat_nano_demo.dart index 1ebabb3..d238179 100644 --- a/firebase_ai_logic_showcase/lib/demos/chat_nano/chat_nano_demo.dart +++ b/firebase_ai_logic_showcase/lib/demos/chat_nano/chat_nano_demo.dart @@ -22,14 +22,13 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:image_picker/image_picker.dart'; import '../../shared/ui/app_frame.dart'; import '../../shared/ui/app_spacing.dart'; +import '../../shared/ui/blaze_warning.dart'; import '../../shared/ui/chat_components/ui_components.dart'; import '../../shared/chat_service.dart'; -import '../../shared/ui/chat_components/model_picker.dart'; import '../../shared/models/models.dart'; class ChatDemoNano extends ConsumerStatefulWidget { - const ChatDemoNano({super.key, this.isSelected = false}); - final bool isSelected; + const ChatDemoNano({super.key}); @override ConsumerState createState() => ChatDemoNanoState(); @@ -47,7 +46,7 @@ class ChatDemoNanoState extends ConsumerState { final ScrollController _scrollController = ScrollController(); bool _loading = false; OverlayPortalController opController = OverlayPortalController(); - static bool _pickerHasBeenShown = false; + static bool _warningHasBeenShown = false; @override void initState() { @@ -57,23 +56,15 @@ class ChatDemoNanoState extends ConsumerState { _chatService.init(); _userTextInputController.text = 'Hot air balloons rising over the San Francisco Bay at golden hour with a view of the Golden Gate Bridge. Make it anime style.'; - _checkAndShowPicker(); + _checkAndShowBlazeWarning(); } - @override - void didUpdateWidget(ChatDemoNano oldWidget) { - super.didUpdateWidget(oldWidget); - if (widget.isSelected != oldWidget.isSelected) { - _checkAndShowPicker(); - } - } - - void _checkAndShowPicker() { - if (widget.isSelected && !_pickerHasBeenShown) { - _pickerHasBeenShown = true; + void _checkAndShowBlazeWarning() { + if (!_warningHasBeenShown) { + _warningHasBeenShown = true; WidgetsBinding.instance.addPostFrameCallback((_) { if (mounted) { - showModelPicker(); + showBlazeWarning(); } }); } @@ -182,20 +173,22 @@ class ChatDemoNanoState extends ConsumerState { } } - void showModelPicker() { + void showBlazeWarning() { showDialog( context: context, builder: (context) { - return ModelPicker( - selectedModel: geminiModels.selectedModel, - onSelected: (value) { - _chatService.changeModel(value); - setState(() { - _userTextInputController.text = - geminiModels.selectedModel.defaultPrompt; - _messages.clear(); - }); - }, + return Dialog( + backgroundColor: Theme.of(context).colorScheme.surfaceContainerLow, + child: ConstrainedBox( + constraints: BoxConstraints(maxWidth: 600), + child: Padding( + padding: const EdgeInsets.all(AppSpacing.s16), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [BlazeWarning()], + ), + ), + ), ); }, ); diff --git a/firebase_ai_logic_showcase/lib/flutter_firebase_ai_demo.dart b/firebase_ai_logic_showcase/lib/flutter_firebase_ai_demo.dart index b14aa79..d9fde64 100644 --- a/firebase_ai_logic_showcase/lib/flutter_firebase_ai_demo.dart +++ b/firebase_ai_logic_showcase/lib/flutter_firebase_ai_demo.dart @@ -59,31 +59,21 @@ class _DemoHomeScreenState extends State { Widget build(BuildContext context) { return LayoutBuilder( builder: (context, constraints) { - if (constraints.maxWidth < 600) { - // Use BottomNavigationBar for smaller screens - return Scaffold( - body: demoPages[_selectedIndex], - bottomNavigationBar: BottomNavigationBar( - type: BottomNavigationBarType.fixed, - items: destinations - .map( - (e) => BottomNavigationBarItem( - icon: e.icon, - label: e.label, - activeIcon: e.selectedIcon, - ), - ) - .toList(), - currentIndex: _selectedIndex, - onTap: _onItemTapped, - ), - ); - } else { - // Use NavigationRail for larger screens - return Scaffold( - body: Row( - children: [ + return Scaffold( + body: Row( + children: [ + if (constraints.maxWidth > + 600) // Show NavigationRail on Medium or larger screens + ...[ NavigationRail( + leading: Padding( + padding: EdgeInsets.all(16), + child: Image.asset( + 'assets/firebase-ai-logic.png', + width: 45, + height: 45, + ), + ), selectedIndex: _selectedIndex, onDestinationSelected: _onItemTapped, labelType: NavigationRailLabelType.all, @@ -101,12 +91,30 @@ class _DemoHomeScreenState extends State { ) .toList(), ), - const VerticalDivider(thickness: 1, width: 1), - Expanded(child: demoPages[_selectedIndex]), + VerticalDivider(thickness: 1, width: 1), ], - ), - ); - } + Expanded(child: demoPages[_selectedIndex]), + ], + ), + bottomNavigationBar: + (constraints.maxWidth < + 600) // Show navigation bar on smaller screens + ? BottomNavigationBar( + type: BottomNavigationBarType.fixed, + items: destinations + .map( + (e) => BottomNavigationBarItem( + icon: e.icon, + label: e.label, + activeIcon: e.selectedIcon, + ), + ) + .toList(), + currentIndex: _selectedIndex, + onTap: _onItemTapped, + ) + : null, + ); }, ); } diff --git a/firebase_ai_logic_showcase/lib/shared/ui/blaze_warning.dart b/firebase_ai_logic_showcase/lib/shared/ui/blaze_warning.dart index 3b23bfb..cf9f875 100644 --- a/firebase_ai_logic_showcase/lib/shared/ui/blaze_warning.dart +++ b/firebase_ai_logic_showcase/lib/shared/ui/blaze_warning.dart @@ -40,10 +40,7 @@ class BlazeWarning extends StatelessWidget { ), TextSpan(text: '.'), TextSpan(text: '\n\n'), - TextSpan( - text: - 'Eligible developers can claim ', - ), + TextSpan(text: 'Eligible developers can claim '), WidgetSpan( baseline: TextBaseline.ideographic, alignment: PlaceholderAlignment.top,