Skip to content
Snippets Groups Projects
Select Git revision
  • 6775c64b948a9ad6c1d4c7f1ebbc59e037094d25
  • master default protected
  • 31-upgrade-framework-and-dependencies
  • 12-improve-ai
  • 14-improve-app-metadata
  • Release_0.8.0_25 protected
  • Release_0.7.2_24 protected
  • Release_0.7.1_23 protected
  • Release_0.7.0_22 protected
  • Release_0.6.0_21 protected
  • Release_0.5.0_20 protected
  • Release_0.4.0_19 protected
  • Release_0.3.2_18 protected
  • Release_0.3.1_17 protected
  • Release_0.3.0_16 protected
  • Release_0.2.1_15 protected
  • Release_0.2.0_14 protected
  • Release_0.1.1_13 protected
  • Release_0.1.0_12 protected
  • Release_0.0.11_11 protected
  • Release_0.0.10_10 protected
  • Release_0.0.9_9 protected
  • Release_0.0.8_8 protected
  • Release_0.0.7_7 protected
  • Release_0.0.6_6 protected
25 results

game_end.dart

Blame
  • game_end.dart 2.60 KiB
    import 'package:flutter/material.dart';
    import 'package:flutter_custom_toolbox/flutter_toolbox.dart';
    
    import 'package:awale/cubit/activity/activity_cubit.dart';
    import 'package:awale/models/activity/activity.dart';
    import 'package:awale/ui/widgets/actions/button_game_quit.dart';
    
    class GameEndWidget extends StatelessWidget {
      const GameEndWidget({
        super.key,
        required this.playerIndex,
        required this.widgetSize,
      });
    
      final int playerIndex;
      final double widgetSize;
    
      @override
      Widget build(BuildContext context) {
        return BlocBuilder<ActivityCubit, ActivityState>(
          builder: (BuildContext context, ActivityState activityState) {
            final Activity currentActivity = activityState.currentActivity;
    
            final String playerImageAsset = currentActivity.scores[playerIndex] ==
                    currentActivity.scores[1 - playerIndex]
                ? 'assets/ui/game_draw.png'
                : (currentActivity.scores[playerIndex] > currentActivity.scores[1 - playerIndex]
                    ? 'assets/ui/game_win.png'
                    : 'assets/ui/game_fail.png');
    
            final Image playerImage = Image(
              image: AssetImage(playerImageAsset),
              fit: BoxFit.fill,
              height: widgetSize,
            );
    
            return RotatedBox(
              quarterTurns: 1 + 2 * playerIndex,
              child: Container(
                margin: const EdgeInsets.all(2),
                padding: const EdgeInsets.all(2),
                height: widgetSize,
                child: Table(
                  defaultColumnWidth: const IntrinsicColumnWidth(),
                  defaultVerticalAlignment: TableCellVerticalAlignment.bottom,
                  children: [
                    TableRow(
                      children: [
                        Column(children: [playerImage]),
                        Column(children: [playerImage]),
                        Column(
                          children: [
                            currentActivity.animationInProgress
                                ? Image(
                                    image: const AssetImage('assets/ui/placeholder.png'),
                                    fit: BoxFit.fill,
                                    height: widgetSize,
                                  )
                                : SizedBox.square(
                                    dimension: 70,
                                    child: QuitGameButton(),
                                  ),
                          ],
                        ),
                        Column(children: [playerImage]),
                        Column(children: [playerImage]),
                      ],
                    ),
                  ],
                ),
              ),
            );
          },
        );
      }
    }