Skip to content
Snippets Groups Projects
Select Git revision
  • dc562485516b6b757c3c5bccc693ada1573dc1fb
  • master default protected
  • 32-upgrade-framework-and-dependencies
  • 15-improve-app-metadata
  • Release_0.9.0_28 protected
  • Release_0.8.2_27 protected
  • Release_0.8.1_26 protected
  • Release_0.8.0_25 protected
  • Release_0.7.0_24 protected
  • Release_0.6.0_23 protected
  • Release_0.5.0_22 protected
  • Release_0.4.2_21 protected
  • Release_0.4.1_20 protected
  • Release_0.4.0_19 protected
  • Release_0.3.1_18 protected
  • Release_0.3.0_17 protected
  • Release_0.2.1_16 protected
  • Release_0.2.0_15 protected
  • Release_0.1.1_14 protected
  • Release_0.1.0_13 protected
  • Release_0.0.12_12 protected
  • Release_0.0.11_11 protected
  • Release_0.0.10_10 protected
  • Release_0.0.9_9 protected
24 results

parameters_layout.dart

Blame
  • parameters_layout.dart 4.35 KiB
    import 'package:flutter/material.dart';
    import 'package:flutter_custom_toolbox/flutter_toolbox.dart';
    
    import 'package:calculus/config/default_game_settings.dart';
    import 'package:calculus/config/default_global_settings.dart';
    import 'package:calculus/cubit/settings_game_cubit.dart';
    import 'package:calculus/cubit/settings_global_cubit.dart';
    import 'package:calculus/ui/parameters/parameter_widget.dart';
    import 'package:calculus/ui/widgets/actions/button_delete_saved_game.dart';
    import 'package:calculus/ui/widgets/actions/button_game_start_new.dart';
    import 'package:calculus/ui/widgets/actions/button_resume_saved_game.dart';
    
    class ParametersLayout extends StatelessWidget {
      const ParametersLayout({super.key, required this.canResume});
    
      final bool canResume;
    
      final double separatorHeight = 8.0;
    
      @override
      Widget build(BuildContext context) {
        final List<Widget> lines = [];
    
        // Game settings
        for (String code in DefaultGameSettings.availableParameters) {
          lines.add(Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: buildParametersLine(
              code: code,
              isGlobal: false,
            ),
          ));
    
          lines.add(SizedBox(height: separatorHeight));
        }
    
        lines.add(Expanded(
          child: SizedBox(height: separatorHeight),
        ));
    
        if (canResume == false) {
          // Start new game
          lines.add(
            const AspectRatio(
              aspectRatio: 3,
              child: StartNewGameButton(),
            ),
          );
        } else {
          // Resume game
          lines.add(const AspectRatio(
            aspectRatio: 3,
            child: ResumeSavedGameButton(),
          ));
          // Delete saved game
          lines.add(SizedBox.square(
            dimension: MediaQuery.of(context).size.width / 5,
            child: const DeleteSavedGameButton(),
          ));
        }
    
        lines.add(SizedBox(height: separatorHeight));
    
        // Global settings
        for (String code in DefaultGlobalSettings.availableParameters) {
          lines.add(Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: buildParametersLine(
              code: code,
              isGlobal: true,