Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide dev bar and subcat button #179

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/pages/categories/add_category.dart
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ class _AddCategoryState extends ConsumerState<AddCategory> with Functions {
],
),
),
/* temporary hided, see #178
Container(
alignment: Alignment.centerLeft,
padding: const EdgeInsets.only(left: 16, top: 32, bottom: 8),
Expand Down Expand Up @@ -289,6 +290,7 @@ class _AddCategoryState extends ConsumerState<AddCategory> with Functions {
),
),
),
*/
if (selectedCategory != null)
Container(
width: double.infinity,
Expand Down
101 changes: 72 additions & 29 deletions lib/pages/settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ import '../providers/dashboard_provider.dart';
import '../providers/statistics_provider.dart';
import '../providers/transactions_provider.dart';

class SettingsPage extends ConsumerStatefulWidget {
const SettingsPage({super.key});

@override
ConsumerState<SettingsPage> createState() => _SettingsPageState();
}

var settingsOptions = [
[
Expand Down Expand Up @@ -70,7 +64,50 @@ var settingsOptions = [
],
];

class SettingsPage extends ConsumerStatefulWidget {
const SettingsPage({super.key});

@override
ConsumerState<SettingsPage> createState() => _SettingsPageState();
}


class _SettingsPageState extends ConsumerState<SettingsPage> {
bool _isDeveloperOptionsActive = false;
int _tapCount = 0;

void _onSettingsTap() {
_tapCount++;

if (_tapCount == 4) {
setState(() {
_isDeveloperOptionsActive = !_isDeveloperOptionsActive;
});
_tapCount = 0; // Reset the tap counter

if (_isDeveloperOptionsActive) {
showDialog(
context: context,
builder: (context) => AlertDialog(
title: const Text("Developer options activated."),
content: const Text("WARNING: tapping on any button on the red bar, erases permanently your data. Do it at your own risk"),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text("OK"),
),
],
),
);
}
}

// Reset the tap count if too much time passes between taps (optional)
Future.delayed(const Duration(seconds: 1), () {
_tapCount = 0;
});
}

@override
Widget build(BuildContext context) {
return Scaffold(
Expand All @@ -86,29 +123,32 @@ class _SettingsPageState extends ConsumerState<SettingsPage> {
children: [
Padding(
padding: const EdgeInsets.symmetric(vertical: 24.0, horizontal: 16.0),
child: Row(
children: [
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Theme.of(context).colorScheme.primary,
child: GestureDetector(
onTap: _onSettingsTap,
child: Row(
children: [
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Theme.of(context).colorScheme.primary,
),
padding: const EdgeInsets.all(5.0),
child: Icon(
Icons.settings,
size: 28.0,
color: Theme.of(context).colorScheme.background,
),
),
padding: const EdgeInsets.all(5.0),
child: Icon(
Icons.settings,
size: 28.0,
color: Theme.of(context).colorScheme.background,
const SizedBox(width: 12.0),
Text(
"Settings",
style: Theme.of(context)
.textTheme
.headlineLarge!
.copyWith(color: Theme.of(context).colorScheme.primary),
),
),
const SizedBox(width: 12.0),
Text(
"Settings",
style: Theme.of(context)
.textTheme
.headlineLarge!
.copyWith(color: Theme.of(context).colorScheme.primary),
),
],
],
),
),
),
ListView.builder(
Expand Down Expand Up @@ -173,7 +213,8 @@ class _SettingsPageState extends ConsumerState<SettingsPage> {
],
),
),
bottomSheet: Container(
bottomSheet: _isDeveloperOptionsActive
? Container(
color: Colors.deepOrangeAccent,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
Expand Down Expand Up @@ -223,7 +264,9 @@ class _SettingsPageState extends ConsumerState<SettingsPage> {
),
],
),
),
)
: null,
);
}
}

Loading