diff --git a/app/lib/pages/persona/persona_profile.dart b/app/lib/pages/persona/persona_profile.dart index df1c300df..1a2be2c0f 100644 --- a/app/lib/pages/persona/persona_profile.dart +++ b/app/lib/pages/persona/persona_profile.dart @@ -114,17 +114,20 @@ class _PersonaProfilePageState extends State { actions: [ // Only show settings icon for create_my_clone or home routing Consumer(builder: (context, personaProvider, _) { - //if (personaProvider.routing == PersonaProfileRouting.no_device) { - // return Padding( - // padding: const EdgeInsets.all(16.0), - // child: GestureDetector( - // onTap: () async { - // _showSignOutDialog(context); - // }, - // child: const Icon(Icons.logout, color: Colors.white, size: 24), - // ), - // ); - //} + if (personaProvider.routing == PersonaProfileRouting.no_device) + return Padding( + padding: const EdgeInsets.all(8.0), + child: GestureDetector( + onTap: () async { + await routeToPage(context, const SettingsPage(mode: SettingsMode.no_device)); + }, + child: SvgPicture.asset( + 'assets/images/ic_setting_persona.svg', + width: 44, + height: 44, + ), + ), + ); if (personaProvider.routing == PersonaProfileRouting.create_my_clone || personaProvider.routing == PersonaProfileRouting.home) return Padding( diff --git a/app/lib/pages/settings/page.dart b/app/lib/pages/settings/page.dart index c438549db..e18c33c39 100644 --- a/app/lib/pages/settings/page.dart +++ b/app/lib/pages/settings/page.dart @@ -15,8 +15,18 @@ import 'package:provider/provider.dart'; import 'device_settings.dart'; +enum SettingsMode { + no_device, + omi, +} + class SettingsPage extends StatefulWidget { - const SettingsPage({super.key}); + final SettingsMode mode; + + const SettingsPage({ + super.key, + this.mode = SettingsMode.omi, + }); @override State createState() => _SettingsPageState(); @@ -45,6 +55,133 @@ class _SettingsPageState extends State { bool loadingExportMemories = false; + Widget _buildOmiModeContent(BuildContext context) { + return Column( + children: [ + const SizedBox(height: 32.0), + getItemAddOn2( + 'Need Help? Chat with us', + () async { + await Intercom.instance.displayMessenger(); + }, + icon: Icons.chat, + ), + const SizedBox(height: 20), + getItemAddOn2( + 'Profile', + () => routeToPage(context, const ProfilePage()), + icon: Icons.person, + ), + const SizedBox(height: 20), + getItemAddOn2( + 'Device Settings', + () { + Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => const DeviceSettings(), + ), + ); + }, + icon: Icons.bluetooth_connected_sharp, + ), + const SizedBox(height: 8), + getItemAddOn2( + 'Guides & Tutorials', + () async { + await Intercom.instance.displayHelpCenter(); + }, + icon: Icons.help_outline_outlined, + ), + const SizedBox(height: 20), + getItemAddOn2( + 'About Omi', + () => routeToPage(context, const AboutOmiPage()), + icon: Icons.workspace_premium_sharp, + ), + const SizedBox(height: 8), + getItemAddOn2('Developer Mode', () async { + await routeToPage(context, const DeveloperSettingsPage()); + setState(() {}); + }, icon: Icons.code), + const SizedBox(height: 32), + getItemAddOn2('Sign Out', () async { + await showDialog( + context: context, + builder: (ctx) { + return getDialog(context, () { + Navigator.of(context).pop(); + }, () async { + SharedPreferencesUtil().hasOmiDevice = null; + SharedPreferencesUtil().verifiedPersonaId = null; + Provider.of(context, listen: false).setRouting(PersonaProfileRouting.no_device); + await signOut(); + Navigator.of(context).pop(); + routeToPage(context, const DeciderWidget(), replace: true); + }, "Sign Out?", "Are you sure you want to sign out?"); + }, + ); + }, icon: Icons.logout), + const SizedBox(height: 24), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 8.0), + child: Align( + alignment: Alignment.center, + child: Text( + 'Version: $version+$buildVersion', + style: const TextStyle(color: Color.fromARGB(255, 150, 150, 150), fontSize: 16), + ), + ), + ), + const SizedBox(height: 32), + ], + ); + } + + Widget _buildNoDeviceModeContent(BuildContext context) { + return Column( + children: [ + const SizedBox(height: 32.0), + getItemAddOn2( + 'Need Help? Chat with us', + () async { + await Intercom.instance.displayMessenger(); + }, + icon: Icons.chat, + ), + const SizedBox(height: 32), + getItemAddOn2('Sign Out', () async { + await showDialog( + context: context, + builder: (ctx) { + return getDialog(context, () { + Navigator.of(context).pop(); + }, () async { + SharedPreferencesUtil().hasOmiDevice = null; + SharedPreferencesUtil().verifiedPersonaId = null; + Provider.of(context, listen: false).setRouting(PersonaProfileRouting.no_device); + await signOut(); + Navigator.of(context).pop(); + routeToPage(context, const DeciderWidget(), replace: true); + }, "Sign Out?", "Are you sure you want to sign out?"); + }, + ); + }, icon: Icons.logout), + const SizedBox(height: 24), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 8.0), + child: Align( + alignment: Alignment.center, + child: Text( + 'Version: $version+$buildVersion', + style: const TextStyle(color: Color.fromARGB(255, 150, 150, 150), fontSize: 16), + ), + ), + ), + const SizedBox(height: 32), + ], + ); + } + @override Widget build(BuildContext context) { return PopScope( @@ -66,86 +203,7 @@ class _SettingsPageState extends State { ), body: SingleChildScrollView( padding: const EdgeInsets.symmetric(horizontal: 16.0), - child: Column( - children: [ - const SizedBox(height: 32.0), - getItemAddOn2( - 'Need Help? Chat with us', - () async { - await Intercom.instance.displayMessenger(); - }, - icon: Icons.chat, - ), - const SizedBox(height: 20), - getItemAddOn2( - 'Profile', - () => routeToPage(context, const ProfilePage()), - icon: Icons.person, - ), - const SizedBox(height: 20), - getItemAddOn2( - 'Device Settings', - () { - Navigator.of(context).push( - MaterialPageRoute( - builder: (context) => const DeviceSettings(), - ), - ); - }, - icon: Icons.bluetooth_connected_sharp, - ), - const SizedBox(height: 8), - getItemAddOn2( - 'Guides & Tutorials', - () async { - await Intercom.instance.displayHelpCenter(); - }, - icon: Icons.help_outline_outlined, - ), - const SizedBox(height: 20), - getItemAddOn2( - 'About Omi', - () => routeToPage(context, const AboutOmiPage()), - icon: Icons.workspace_premium_sharp, - ), - const SizedBox(height: 8), - getItemAddOn2('Developer Mode', () async { - await routeToPage(context, const DeveloperSettingsPage()); - setState(() {}); - }, icon: Icons.code), - const SizedBox(height: 32), - getItemAddOn2('Sign Out', () async { - await showDialog( - context: context, - builder: (ctx) { - return getDialog(context, () { - Navigator.of(context).pop(); - }, () async { - SharedPreferencesUtil().hasOmiDevice = null; - SharedPreferencesUtil().verifiedPersonaId = null; - Provider.of(context, listen: false) - .setRouting(PersonaProfileRouting.no_device); - await signOut(); - Navigator.of(context).pop(); - routeToPage(context, const DeciderWidget(), replace: true); - }, "Sign Out?", "Are you sure you want to sign out?"); - }, - ); - }, icon: Icons.logout), - const SizedBox(height: 24), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 8.0), - child: Align( - alignment: Alignment.center, - child: Text( - 'Version: $version+$buildVersion', - style: const TextStyle(color: Color.fromARGB(255, 150, 150, 150), fontSize: 16), - ), - ), - ), - const SizedBox(height: 32), - ], - ), + child: widget.mode == SettingsMode.omi ? _buildOmiModeContent(context) : _buildNoDeviceModeContent(context), ), )); }