Skip to content
Snippets Groups Projects
Select Git revision
  • 5f6335e98e1016462f68f5cd8f89c24264a3f434
  • master default protected
  • 84-improve-app-metadata
  • 82-fix-colors
  • 23-add-timer
  • 65-update-icons
  • Release_0.10.1_88 protected
  • Release_0.10.0_87 protected
  • Release_0.9.2_86 protected
  • Release_0.9.1_85 protected
  • Release_0.9.0_84 protected
  • Release_0.8.0_83 protected
  • Release_0.7.0_82 protected
  • Release_0.6.0_81 protected
  • Release_0.5.2_80 protected
  • Release_0.5.1_79 protected
  • Release_0.5.0_78 protected
  • Release_0.4.1_77 protected
  • Release_0.4.0_76 protected
  • Release_0.3.1_75 protected
  • Release_0.3.0_74 protected
  • Release_0.2.1_73 protected
  • Release_0.2.0_72 protected
  • Release_0.1.22_71 protected
  • Release_0.1.21_70 protected
  • Release_0.1.20_69 protected
26 results

cell.dart

Blame
  • global_app_bar.dart 2.76 KiB
    import 'package:flutter/material.dart';
    import 'package:flutter_bloc/flutter_bloc.dart';
    
    import 'package:minehunter/config/menu.dart';
    import 'package:minehunter/cubit/game_cubit.dart';
    import 'package:minehunter/cubit/nav_cubit.dart';
    import 'package:minehunter/models/game/game.dart';
    import 'package:minehunter/ui/helpers/app_titles.dart';
    
    class GlobalAppBar extends StatelessWidget implements PreferredSizeWidget {
      const GlobalAppBar({super.key});
    
      @override
      Widget build(BuildContext context) {
        return BlocBuilder<GameCubit, GameState>(
          builder: (BuildContext context, GameState gameState) {
            return BlocBuilder<NavCubit, int>(
              builder: (BuildContext context, int pageIndex) {
                final Game currentGame = gameState.currentGame;
    
                final List<Widget> menuActions = [];
    
                if (currentGame.isRunning && !currentGame.isFinished) {
                  menuActions.add(TextButton(
                    child: const Image(
                      image: AssetImage('assets/ui/button_back.png'),
                      fit: BoxFit.fill,
                    ),
                    onPressed: () {},
                    onLongPress: () {
                      BlocProvider.of<GameCubit>(context).quitGame();
                    },
                  ));
                } else {
                  if (pageIndex == Menu.indexGame) {
                    // go to Settings page
                    menuActions.add(ElevatedButton(
                      onPressed: () {
                        context.read<NavCubit>().goToSettingsPage();
                      },
                      style: ElevatedButton.styleFrom(
                        shape: const CircleBorder(),
                      ),
                      child: Menu.menuItemSettings.icon,
                    ));
    
                    // go to About page
                    menuActions.add(ElevatedButton(
                      onPressed: () {
                        context.read<NavCubit>().goToAboutPage();
                      },
                      style: ElevatedButton.styleFrom(
                        shape: const CircleBorder(),
                      ),
                      child: Menu.menuItemAbout.icon,
                    ));
                  } else {
                    // back to Home page
                    menuActions.add(ElevatedButton(
                      onPressed: () {
                        context.read<NavCubit>().goToGamePage();
                      },
                      style: ElevatedButton.styleFrom(
                        shape: const CircleBorder(),
                      ),
                      child: Menu.menuItemGame.icon,
                    ));
                  }
                }