Skip to content
Snippets Groups Projects
Select Git revision
  • d9511a97a135ba2f9cd78bc0f8b845c4a6d2521d
  • master default protected
  • 61-upgrade-framework-and-dependencies
  • 44-improve-app-metadata
  • Release_0.10.0_57 protected
  • Release_0.9.2_56 protected
  • Release_0.9.1_55 protected
  • Release_0.9.0_54 protected
  • Release_0.8.0_53 protected
  • Release_0.7.0_52 protected
  • Release_0.6.0_51 protected
  • Release_0.5.3_50 protected
  • Release_0.5.2_49 protected
  • Release_0.5.1_48 protected
  • Release_0.5.0_47 protected
  • Release_0.4.1_46 protected
  • Release_0.4.0_45 protected
  • Release_0.3.1_44 protected
  • Release_0.3.0_43 protected
  • Release_0.2.1_42 protected
  • Release_0.2.0_41 protected
  • Release_0.1.19_40 protected
  • Release_0.1.18_39 protected
  • Release_0.1.17_38 protected
24 results

Debug.xcconfig

Blame
  • global_app_bar.dart 3.06 KiB
    import 'package:flutter/material.dart';
    import 'package:flutter_custom_toolbox/flutter_toolbox.dart';
    
    import 'package:puzzlegame/common/config/screen.dart';
    import 'package:puzzlegame/common/cubit/nav/nav_cubit_pages.dart';
    import 'package:puzzlegame/common/cubit/nav/nav_cubit_screens.dart';
    
    import 'package:puzzlegame/cubit/activity/activity_cubit.dart';
    import 'package:puzzlegame/models/activity/activity.dart';
    
    class GlobalAppBar extends StatelessWidget implements PreferredSizeWidget {
      const GlobalAppBar({super.key});
    
      @override
      Widget build(BuildContext context) {
        return BlocBuilder<ActivityCubit, ActivityState>(
          builder: (BuildContext context, ActivityState activityState) {
            return BlocBuilder<NavCubitScreen, int>(
              builder: (BuildContext context, int pageIndex) {
                final Activity currentActivity = activityState.currentActivity;
    
                final List<Widget> menuActions = [];
    
                if (currentActivity.isRunning && !currentActivity.isFinished) {
                  menuActions.add(StyledButton(
                    color: Colors.red,
                    onPressed: () {},
                    onLongPress: () {
                      BlocProvider.of<ActivityCubit>(context).quitActivity();
                      BlocProvider.of<NavCubitPage>(context).goToPageHome();
                    },
                    child: const Image(
                      image: AssetImage('assets/ui/button_back.png'),
                      fit: BoxFit.fill,
                    ),
                  ));
                } else {
                  if (pageIndex == Screen.indexActivity) {
                    // go to Settings page
                    menuActions.add(ElevatedButton(
                      onPressed: () {
                        BlocProvider.of<NavCubitScreen>(context).goToScreenSettings();
                      },
                      style: ElevatedButton.styleFrom(
                        shape: const CircleBorder(),
                      ),
                      child: Screen.screenSettings.icon,
                    ));
    
                    // go to About page
                    menuActions.add(ElevatedButton(
                      onPressed: () {
                        BlocProvider.of<NavCubitScreen>(context).goToScreenAbout();
                      },
                      style: ElevatedButton.styleFrom(
                        shape: const CircleBorder(),
                      ),
                      child: Screen.screenAbout.icon,
                    ));
                  } else {
                    // back to Home page
                    menuActions.add(ElevatedButton(
                      onPressed: () {
                        BlocProvider.of<NavCubitScreen>(context).goToScreenActivity();
                      },
                      style: ElevatedButton.styleFrom(
                        shape: const CircleBorder(),
                      ),
                      child: Screen.screenActivity.icon,
                    ));
                  }
                }
    
                return AppBar(
                  title: const AppHeader(text: 'app_name'),
                  actions: menuActions,
                );
              },
            );
          },
        );
      }
    
      @override
      Size get preferredSize => const Size.fromHeight(50);
    }