Skip to content
Snippets Groups Projects
Select Git revision
  • master
  • 49-upgrade-framework-and-dependencies
  • 32-improve-app-metadata
  • Release_0.9.0_43 protected
  • Release_0.8.2_42 protected
  • Release_0.8.1_41 protected
  • Release_0.8.0_40 protected
  • Release_0.7.0_39 protected
  • Release_0.6.0_38 protected
  • Release_0.5.0_37 protected
  • Release_0.4.2_36 protected
  • Release_0.4.1_35 protected
  • Release_0.4.0_34 protected
  • Release_0.3.1_33 protected
  • Release_0.3.0_32 protected
  • Release_0.2.1_31 protected
  • Release_0.2.0_30 protected
  • Release_0.1.2_29 protected
  • Release_0.1.1_28 protected
  • Release_0.1.0_27 protected
  • Release_0.0.26_26 protected
  • Release_0.0.25_25 protected
  • Release_0.0.24_24 protected
23 results

analysis_options.yaml

Blame
  • parameter_painter.dart 8.13 KiB
    import 'dart:math';
    
    import 'package:flutter/material.dart';
    
    import 'package:jeweled/config/default_game_settings.dart';
    import 'package:jeweled/models/game_settings.dart';
    import 'package:jeweled/utils/color_extensions.dart';
    import 'package:jeweled/utils/color_theme.dart';
    
    class ParameterPainter extends CustomPainter {
      const ParameterPainter({
        required this.code,
        required this.value,
        required this.isSelected,
        required this.gameSettings,
      });
    
      final String code;
      final int value;
      final bool isSelected;
      final GameSettings gameSettings;
    
      @override
      void paint(Canvas canvas, Size size) {
        // force square
        final double canvasSize = min(size.width, size.height);
    
        const Color borderColorEnabled = Colors.blue;
        const Color borderColorDisabled = Colors.white;
    
        // "enabled/disabled" border
        final paint = Paint();
        paint.style = PaintingStyle.stroke;
        paint.color = this.isSelected ? borderColorEnabled : borderColorDisabled;
        paint.strokeJoin = StrokeJoin.round;
        paint.strokeWidth = 20 / 100 * canvasSize;
        canvas.drawRect(Rect.fromPoints(Offset(0, 0), Offset(canvasSize, canvasSize)), paint);
    
        // content
        switch (code) {
          case 'colorsCount':
            paintColorsCountParameterItem(value, canvas, canvasSize);
            break;
          case 'boardSize':
            paintBoardSizeParameterItem(value, canvas, canvasSize);
            break;
          case 'colorsTheme':
            paintColorsThemeParameterItem(value, canvas, canvasSize);
            break;
          default:
            print('Unknown parameter: ' + code + '/' + value.toString());
            paintUnknownParameterItem(value, canvas, canvasSize);
        }
      }
    
      @override
      bool shouldRepaint(CustomPainter oldDelegate) {
        return false;
      }
    
      // "unknown" parameter -> simple bock with text
      void paintUnknownParameterItem(final int value, final Canvas canvas, final double size) {
        final textSpan = TextSpan(
          text: '?' + '\n' + value.toString(),
          style: const TextStyle(
            color: Colors.black,
            fontSize: 18,
            fontWeight: FontWeight.bold,
          ),
        );