import 'package:auto_route/annotations.dart'; import 'package:drift/src/runtime/api/runtime_api.dart'; import 'package:drift_db_viewer/drift_db_viewer.dart'; import 'package:flutter/material.dart'; import 'package:get_it_mixin/get_it_mixin.dart'; import 'package:package_info_plus/package_info_plus.dart'; import 'package:remever/common/widgets/typography.dart'; import 'package:remever/common/widgets/wspace.dart'; import 'package:remever/database/database.dart'; import '../../components/notifiers/app_settings.dart'; import '../../components/env.dart'; import '../../inject.dart'; @RoutePage() class SandboxScreen extends StatefulWidget { const SandboxScreen({super.key}); @override State createState() => _SandboxScreenState(); } class _SandboxScreenState extends State { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: const AppTypography('Песочница')), body: ListView( padding: const EdgeInsets.all(16), children: [ _buildVersion(), const HSpace(8), Text('${getIt().runtimeType}:${getIt().url}'), const HSpace(8), _debugBox(), const HSpace(8), ], ), ); } Widget _debugBox() { return DecoratedBox( decoration: const BoxDecoration( border: Border.fromBorderSide( BorderSide(width: 1, color: Colors.black), ), borderRadius: BorderRadius.all(Radius.circular(4)), ), child: Column( children: [ const AppTypography('debug'), ShowFpsSetting(), EnableDebugSetting(), ElevatedButton( onPressed: () { Navigator.of(context).push( MaterialPageRoute( builder: (BuildContext context) { return DriftDbViewer(getIt()); }, ), ); }, child: const Text('Open Db Viewer'), ), ], ), ); } Widget _buildVersion() { return FutureBuilder( future: PackageInfo.fromPlatform(), builder: (BuildContext context, AsyncSnapshot snapshot) { return AppTypography( 'Версия: ${snapshot.data?.version ?? '-'}' '+${snapshot.data?.buildNumber ?? '-'}', type: Bold14px(), //color: Colors.black, ); }, ); } } class ShowFpsSetting extends StatelessWidget with GetItMixin { /// /// Виджет для контроля показа FPS /// ShowFpsSetting({super.key}); @override Widget build(BuildContext context) { final bool showFPS = watchOnly( (AppSettingsNotifier e) => e.showFps, ); return SwitchListTile.adaptive( value: showFPS, title: const Text('Show FPS'), activeColor: Colors.blueAccent, onChanged: (_) { if (context.mounted) get().toggleFps(); }, ); } } class EnableDebugSetting extends StatelessWidget with GetItMixin { /// /// Виджет для включения общего дебага /// EnableDebugSetting({super.key}); @override Widget build(BuildContext context) { final bool debugMode = watchOnly( (AppSettingsNotifier e) => e.debugMode, ); return SwitchListTile.adaptive( value: debugMode, title: const Text('Debug mode'), activeColor: Colors.blueAccent, onChanged: (_) => get().toggleDebugMode(), ); } }