Skip to content
Snippets Groups Projects
Select Git revision
  • 8f23c0a3548d0799185527a6965bc4c8b98c98b9
  • master default protected
  • 21-add-onlongpress-with-popup-on-parameters
  • 23-center-vertically-buttons
  • 30-highlight-bin-when-selecting-disabled-item
  • 1.0.7 protected
  • 1.0.6 protected
  • 1.0.5 protected
  • 1.0.4 protected
  • 1.0.3 protected
  • 1.0.2 protected
  • 1.0.0 protected
  • 0.9.1 protected
  • 0.9.0 protected
  • 0.8.4 protected
  • 0.8.3 protected
  • 0.8.2 protected
  • 0.8.1 protected
  • 0.8.0 protected
  • 0.7.0 protected
  • 0.6.1 protected
  • 0.6.0 protected
  • 0.5.0 protected
  • 0.4.0 protected
  • 0.3.0 protected
25 results

button_resume_saved_activity.dart

Blame
  • parameter_painter.dart 4.01 KiB
    import 'dart:math';
    
    import 'package:flutter/material.dart';
    
    import 'package:hangman/config/default_game_settings.dart';
    import 'package:hangman/models/settings/settings_game.dart';
    import 'package:hangman/models/settings/settings_global.dart';
    import 'package:hangman/utils/tools.dart';
    
    class ParameterPainter extends CustomPainter {
      const ParameterPainter({
        required this.code,
        required this.value,
        required this.gameSettings,
        required this.globalSettings,
      });
    
      final String code;
      final String value;
      final GameSettings gameSettings;
      final GlobalSettings globalSettings;
    
      @override
      void paint(Canvas canvas, Size size) {
        // force square
        final double canvasSize = min(size.width, size.height);
    
        // content
        switch (code) {
          case DefaultGameSettings.parameterCodeGameMode:
            paintGameModeParameterItem(canvas, canvasSize);
            break;
          case DefaultGameSettings.parameterCodeGameLevel:
            paintGameLevelParameterItem(canvas, canvasSize);
            break;
          default:
            printlog('Unknown parameter: $code/$value');
            paintUnknownParameterItem(canvas, canvasSize);
        }
      }
    
      @override
      bool shouldRepaint(CustomPainter oldDelegate) {
        return false;
      }
    
      // "unknown" parameter -> simple block with text
      void paintUnknownParameterItem(
        final Canvas canvas,
        final double size,
      ) {
        final paint = Paint();
        paint.strokeJoin = StrokeJoin.round;
        paint.strokeWidth = 3;
    
        final textSpan = TextSpan(
          text: '$code\n$value',
          style: const TextStyle(
            color: Colors.black,
            fontSize: 18,
            fontWeight: FontWeight.bold,
          ),
        );
        final textPainter = TextPainter(
          text: textSpan,
          textDirection: TextDirection.ltr,
          textAlign: TextAlign.center,
        );
        textPainter.layout();
        textPainter.paint(