feat(settings): implement debug menu toggle in settings tab with version label tap detection
This commit is contained in:
@@ -0,0 +1,56 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:material_symbols_icons/symbols.dart';
|
||||||
|
|
||||||
|
class DebugMenuScreen extends StatelessWidget {
|
||||||
|
const DebugMenuScreen({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final cs = Theme.of(context).colorScheme;
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: cs.surface,
|
||||||
|
body: SafeArea(
|
||||||
|
bottom: false,
|
||||||
|
child: CustomScrollView(
|
||||||
|
physics: const BouncingScrollPhysics(),
|
||||||
|
slivers: [
|
||||||
|
SliverToBoxAdapter(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 4),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(
|
||||||
|
Symbols.arrow_back,
|
||||||
|
color: cs.onSurface,
|
||||||
|
size: 24,
|
||||||
|
weight: 400,
|
||||||
|
),
|
||||||
|
onPressed: () => Navigator.pop(context),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 4),
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
'Для разработчиков',
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: TextStyle(
|
||||||
|
color: cs.onSurface,
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.w700,
|
||||||
|
fontFamily: 'Outfit',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SliverToBoxAdapter(child: SizedBox(height: 120)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,10 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:material_symbols_icons/symbols.dart';
|
import 'package:material_symbols_icons/symbols.dart';
|
||||||
import 'package:package_info_plus/package_info_plus.dart';
|
import 'package:package_info_plus/package_info_plus.dart';
|
||||||
import '../../../core/storage/app_database.dart';
|
import '../../../core/storage/app_database.dart';
|
||||||
|
import 'debug_menu_screen.dart';
|
||||||
import 'devices_screen.dart';
|
import 'devices_screen.dart';
|
||||||
import 'security_screen.dart';
|
import 'security_screen.dart';
|
||||||
import 'spoof_screen.dart';
|
import 'spoof_screen.dart';
|
||||||
@@ -17,6 +20,9 @@ class _SettingsTabState extends State<SettingsTab> {
|
|||||||
ProfileData? _profile;
|
ProfileData? _profile;
|
||||||
bool _isPhoneVisible = false;
|
bool _isPhoneVisible = false;
|
||||||
String? _appVersionLabel;
|
String? _appVersionLabel;
|
||||||
|
bool _debugMenuVisible = false;
|
||||||
|
int _versionSecretTapCount = 0;
|
||||||
|
Timer? _versionSecretTapResetTimer;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -25,6 +31,31 @@ class _SettingsTabState extends State<SettingsTab> {
|
|||||||
_loadAppVersion();
|
_loadAppVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_versionSecretTapResetTimer?.cancel();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _scheduleVersionSecretTapReset() {
|
||||||
|
_versionSecretTapResetTimer?.cancel();
|
||||||
|
_versionSecretTapResetTimer = Timer(const Duration(seconds: 2), () {
|
||||||
|
if (mounted) setState(() => _versionSecretTapCount = 0);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _onVersionLabelTap() {
|
||||||
|
_scheduleVersionSecretTapReset();
|
||||||
|
setState(() {
|
||||||
|
_versionSecretTapCount++;
|
||||||
|
if (_versionSecretTapCount >= 7) {
|
||||||
|
_versionSecretTapCount = 0;
|
||||||
|
_versionSecretTapResetTimer?.cancel();
|
||||||
|
_debugMenuVisible = !_debugMenuVisible;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> _loadProfile() async {
|
Future<void> _loadProfile() async {
|
||||||
final p = await AppDatabase.loadActiveProfile();
|
final p = await AppDatabase.loadActiveProfile();
|
||||||
if (mounted) setState(() => _profile = p);
|
if (mounted) setState(() => _profile = p);
|
||||||
@@ -127,18 +158,86 @@ class _SettingsTabState extends State<SettingsTab> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
SliverToBoxAdapter(
|
||||||
|
child: AnimatedSwitcher(
|
||||||
|
duration: const Duration(milliseconds: 340),
|
||||||
|
switchInCurve: Curves.easeOutCubic,
|
||||||
|
switchOutCurve: Curves.easeInCubic,
|
||||||
|
transitionBuilder: (child, animation) {
|
||||||
|
return ClipRect(
|
||||||
|
child: Align(
|
||||||
|
alignment: Alignment.topCenter,
|
||||||
|
heightFactor: animation.value.clamp(0.0, 1.0),
|
||||||
|
child: FadeTransition(
|
||||||
|
opacity: animation,
|
||||||
|
child: child,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
layoutBuilder: (currentChild, previousChildren) {
|
||||||
|
return Stack(
|
||||||
|
alignment: Alignment.topCenter,
|
||||||
|
clipBehavior: Clip.none,
|
||||||
|
children: <Widget>[
|
||||||
|
...previousChildren,
|
||||||
|
?currentChild,
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: _debugMenuVisible
|
||||||
|
? KeyedSubtree(
|
||||||
|
key: const ValueKey('developers_settings_row'),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.fromLTRB(16, 12, 16, 0),
|
||||||
|
child: _buildSection(
|
||||||
|
context,
|
||||||
|
cs,
|
||||||
|
items: [
|
||||||
|
_SettingsItem(
|
||||||
|
icon: Symbols.construction,
|
||||||
|
label: 'Для разработчиков',
|
||||||
|
onTap: () {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) =>
|
||||||
|
const DebugMenuScreen(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: const SizedBox.shrink(
|
||||||
|
key: ValueKey('developers_settings_hidden'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
if (_appVersionLabel != null)
|
if (_appVersionLabel != null)
|
||||||
SliverToBoxAdapter(
|
SliverToBoxAdapter(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.fromLTRB(16, 28, 16, 12),
|
padding: const EdgeInsets.fromLTRB(16, 28, 16, 12),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Text(
|
child: GestureDetector(
|
||||||
_appVersionLabel!,
|
behavior: HitTestBehavior.opaque,
|
||||||
textAlign: TextAlign.center,
|
onTap: _onVersionLabelTap,
|
||||||
style: TextStyle(
|
child: Padding(
|
||||||
color: cs.onSurfaceVariant.withValues(alpha: 0.75),
|
padding: const EdgeInsets.symmetric(
|
||||||
fontSize: 13,
|
horizontal: 24,
|
||||||
fontWeight: FontWeight.w400,
|
vertical: 8,
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
_appVersionLabel!,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
color: cs.onSurfaceVariant.withValues(alpha: 0.75),
|
||||||
|
fontSize: 13,
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user