2023-12-17 23:00:31 +01:00
|
|
|
import 'package:flutter/material.dart';
|
2024-01-01 22:55:30 +01:00
|
|
|
import 'package:url_launcher/url_launcher.dart';
|
2024-01-01 18:31:10 +01:00
|
|
|
import 'package:go_router/go_router.dart';
|
2023-12-17 23:00:31 +01:00
|
|
|
|
2024-01-08 19:34:48 +01:00
|
|
|
import '../../utils/definitions/style_guide.dart';
|
2024-01-09 12:34:44 +01:00
|
|
|
import '../../utils/logic/preferences_service.dart';
|
|
|
|
import '../../utils/widgets/custom_bottom_navigation_bar.dart';
|
|
|
|
import 'widgets/custom_divider_widget.dart';
|
|
|
|
import 'widgets/set_pin_popup_widget.dart';
|
|
|
|
import 'widgets/text_switch_container_widget.dart';
|
2023-12-17 23:00:31 +01:00
|
|
|
|
2024-01-01 19:52:42 +01:00
|
|
|
class SettingsPage extends StatefulWidget {
|
2024-01-09 12:34:44 +01:00
|
|
|
const SettingsPage({super.key});
|
|
|
|
|
2024-01-01 19:52:42 +01:00
|
|
|
@override
|
2024-01-09 12:34:44 +01:00
|
|
|
State<SettingsPage> createState() => _SettingsPage();
|
2024-01-01 19:52:42 +01:00
|
|
|
}
|
|
|
|
|
2024-01-09 12:34:44 +01:00
|
|
|
class _SettingsPage extends State<SettingsPage> {
|
2024-01-01 19:52:42 +01:00
|
|
|
bool isPinEnabled = false; // Default to false
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
_loadPinEnabledState();
|
|
|
|
}
|
|
|
|
|
|
|
|
void _loadPinEnabledState() async {
|
|
|
|
isPinEnabled = await PreferencesService().isPinEnabled();
|
|
|
|
setState(() {});
|
|
|
|
}
|
|
|
|
|
2024-01-01 22:55:30 +01:00
|
|
|
Future<void> _launchUrl(Uri _url) async {
|
|
|
|
if (!await launchUrl(_url)) {
|
|
|
|
throw Exception('Could not launch $_url');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-17 23:00:31 +01:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-12-20 17:24:18 +01:00
|
|
|
return Scaffold(
|
2024-01-08 19:34:48 +01:00
|
|
|
backgroundColor: AppStyle.backgroundColor,
|
2024-01-01 18:31:10 +01:00
|
|
|
body: Container(
|
2024-01-09 12:34:44 +01:00
|
|
|
padding: const EdgeInsets.only(bottom: 0),
|
2024-01-01 18:31:10 +01:00
|
|
|
margin: const EdgeInsets.fromLTRB(30, 30, 30, 0),
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
child: Column(
|
|
|
|
children: <Widget>[
|
|
|
|
const SizedBox(
|
|
|
|
height: 100,
|
|
|
|
),
|
|
|
|
|
|
|
|
// Settings section
|
|
|
|
Container(
|
2024-01-09 12:34:44 +01:00
|
|
|
margin: const EdgeInsets.only(bottom: 10),
|
2024-01-01 18:31:10 +01:00
|
|
|
alignment: Alignment.topLeft,
|
2024-01-09 12:34:44 +01:00
|
|
|
child: const Text('settings', style: TextStyle(fontWeight: FontWeight.w500, fontSize: 24)),
|
2024-01-01 18:31:10 +01:00
|
|
|
),
|
|
|
|
TextSwitchContainer(
|
|
|
|
leftText: "change color",
|
|
|
|
onTap: () => context.go("/color"),
|
|
|
|
),
|
2024-01-09 12:34:44 +01:00
|
|
|
const CustomDivider(),
|
2024-01-01 19:52:42 +01:00
|
|
|
FutureBuilder<bool>(
|
|
|
|
future: PreferencesService().isPinEnabled(),
|
|
|
|
builder: (context, snapshot) {
|
|
|
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
2024-01-09 12:34:44 +01:00
|
|
|
return const CircularProgressIndicator(); // or some other placeholder
|
2024-01-01 19:52:42 +01:00
|
|
|
}
|
2024-01-08 19:34:48 +01:00
|
|
|
bool pinEnabled = snapshot.data ?? false; // Default to false if null
|
2024-01-01 19:52:42 +01:00
|
|
|
return TextSwitchContainer(
|
|
|
|
leftText: "pin",
|
|
|
|
hasSwitch: true,
|
|
|
|
onTap: () => {showSetPinPopup(context)},
|
|
|
|
onSwitchToggle: (value) {
|
|
|
|
if (value) {
|
|
|
|
PreferencesService().enablePin();
|
|
|
|
} else {
|
|
|
|
PreferencesService().disablePin();
|
|
|
|
}
|
|
|
|
// Consider updating the state here or using other state management
|
|
|
|
},
|
|
|
|
switchDefaultValue: pinEnabled,
|
|
|
|
);
|
|
|
|
},
|
2024-01-01 18:31:10 +01:00
|
|
|
),
|
2024-01-09 12:34:44 +01:00
|
|
|
const CustomDivider(),
|
2024-01-01 18:31:10 +01:00
|
|
|
TextSwitchContainer(
|
|
|
|
leftText: "your data",
|
2024-01-09 12:34:44 +01:00
|
|
|
onTap: () => {},
|
2024-01-01 18:31:10 +01:00
|
|
|
),
|
|
|
|
// Community section
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.fromLTRB(0, 50, 0, 10),
|
|
|
|
child: Container(
|
|
|
|
alignment: Alignment.topLeft,
|
2024-01-09 12:34:44 +01:00
|
|
|
margin: const EdgeInsets.only(bottom: 10),
|
|
|
|
child: const Text('community', style: TextStyle(fontWeight: FontWeight.w500, fontSize: 24)),
|
2024-01-01 18:31:10 +01:00
|
|
|
),
|
|
|
|
),
|
|
|
|
TextSwitchContainer(
|
|
|
|
leftText: "join our discord",
|
|
|
|
rightText: "fullfilled",
|
2024-01-01 22:55:30 +01:00
|
|
|
onTap: () async => {
|
|
|
|
await _launchUrl(Uri.parse("https://www.google.com"))
|
|
|
|
|
|
|
|
}, // Implement your logic
|
2024-01-01 18:31:10 +01:00
|
|
|
),
|
2024-01-09 12:34:44 +01:00
|
|
|
const CustomDivider(),
|
2024-01-01 18:31:10 +01:00
|
|
|
TextSwitchContainer(
|
|
|
|
leftText: "our instagram",
|
2024-01-08 19:34:48 +01:00
|
|
|
rightText: "@get.fulfilled",
|
2024-01-09 12:34:44 +01:00
|
|
|
onTap: () => {},
|
2024-01-01 18:31:10 +01:00
|
|
|
),
|
2024-01-09 12:34:44 +01:00
|
|
|
const CustomDivider(),
|
2024-01-01 18:31:10 +01:00
|
|
|
TextSwitchContainer(
|
2024-01-08 19:34:48 +01:00
|
|
|
leftText: "share fulfilled with your loved ones",
|
2024-01-09 12:34:44 +01:00
|
|
|
onTap: () => {},
|
2024-01-01 18:31:10 +01:00
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.fromLTRB(0, 50, 0, 10),
|
|
|
|
child: Container(
|
|
|
|
alignment: Alignment.topLeft,
|
2024-01-09 12:34:44 +01:00
|
|
|
child: const Text('humans behind fulfilled', style: TextStyle(fontWeight: FontWeight.w500, fontSize: 24)),
|
2024-01-01 18:31:10 +01:00
|
|
|
),
|
|
|
|
),
|
|
|
|
TextSwitchContainer(
|
|
|
|
leftText: "about us",
|
2024-01-09 12:34:44 +01:00
|
|
|
onTap: () => {},
|
2024-01-01 18:31:10 +01:00
|
|
|
),
|
2024-01-09 12:34:44 +01:00
|
|
|
const CustomDivider(),
|
2024-01-01 18:31:10 +01:00
|
|
|
TextSwitchContainer(
|
|
|
|
leftText: "support us",
|
2024-01-09 12:34:44 +01:00
|
|
|
onTap: () => {},
|
2024-01-01 18:31:10 +01:00
|
|
|
),
|
2024-01-09 12:34:44 +01:00
|
|
|
const CustomDivider(),
|
2024-01-01 18:31:10 +01:00
|
|
|
TextSwitchContainer(
|
|
|
|
leftText: "give feedback",
|
2024-01-09 12:34:44 +01:00
|
|
|
onTap: () => {},
|
2024-01-01 18:31:10 +01:00
|
|
|
),
|
|
|
|
//
|
|
|
|
ListTile(
|
2024-01-09 12:34:44 +01:00
|
|
|
title: const Text('imprint & privacy policy', style: TextStyle(color: Colors.grey, fontSize: 15)),
|
2024-01-01 18:31:10 +01:00
|
|
|
onTap: () => {}, // Implement your logic
|
|
|
|
),
|
2024-01-09 12:34:44 +01:00
|
|
|
const SizedBox(
|
2024-01-01 18:31:10 +01:00
|
|
|
height: 150,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
2023-12-17 23:00:31 +01:00
|
|
|
),
|
2023-12-20 17:24:18 +01:00
|
|
|
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
|
2024-01-09 12:34:44 +01:00
|
|
|
floatingActionButton: const CustomBottomNavigationBar(initialSelectedIndex: 2),
|
2024-01-01 18:31:10 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
void showSetPinPopup(BuildContext context) {
|
|
|
|
showDialog(
|
|
|
|
context: context,
|
|
|
|
builder: (BuildContext context) {
|
2024-01-09 12:34:44 +01:00
|
|
|
return const SetPinPopup();
|
2024-01-01 18:31:10 +01:00
|
|
|
},
|
2023-12-17 23:00:31 +01:00
|
|
|
);
|
|
|
|
}
|
2023-12-25 14:10:31 +01:00
|
|
|
}
|