Skip to content

Commit

Permalink
Add settings to no device persona profile
Browse files Browse the repository at this point in the history
  • Loading branch information
beastoin committed Feb 26, 2025
1 parent d05feab commit 15e61ff
Show file tree
Hide file tree
Showing 2 changed files with 153 additions and 92 deletions.
25 changes: 14 additions & 11 deletions app/lib/pages/persona/persona_profile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,20 @@ class _PersonaProfilePageState extends State<PersonaProfilePage> {
actions: [
// Only show settings icon for create_my_clone or home routing
Consumer<PersonaProvider>(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(
Expand Down
220 changes: 139 additions & 81 deletions app/lib/pages/settings/page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<SettingsPage> createState() => _SettingsPageState();
Expand Down Expand Up @@ -45,6 +55,133 @@ class _SettingsPageState extends State<SettingsPage> {

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<PersonaProvider>(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<PersonaProvider>(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(
Expand All @@ -66,86 +203,7 @@ class _SettingsPageState extends State<SettingsPage> {
),
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<PersonaProvider>(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),
),
));
}
Expand Down

0 comments on commit 15e61ff

Please sign in to comment.