import 'package:flutter/material.dart';

import '../speed_button.dart';

class AndroidSpeedStrip extends StatelessWidget {
  const AndroidSpeedStrip({
    super.key,
    required this.currentRate,
    required this.onIncrement,
    required this.onDecrement,
    required this.onTapRate,
  });

  final double currentRate;
  final VoidCallback onIncrement;
  final VoidCallback onDecrement;
  final VoidCallback onTapRate;

  @override
  Widget build(BuildContext context) {
    const buttonConstraints = BoxConstraints(minWidth: 36, minHeight: 36);

    return Container(
      padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 4),
      decoration: BoxDecoration(
        color: const Color(0xB3000000),
        borderRadius: BorderRadius.circular(24),
      ),
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          IconButton(
            onPressed: onIncrement,
            icon: const Icon(Icons.add, size: 20, color: Colors.white),
            constraints: buttonConstraints,
            padding: EdgeInsets.zero,
          ),
          GestureDetector(
            onTap: onTapRate,
            child: Padding(
              padding: const EdgeInsets.symmetric(vertical: 8),
              child: Text(
                SpeedButton.formatRate(currentRate),
                style: const TextStyle(
                  color: Colors.white,
                  fontSize: 13,
                  fontFeatures: [FontFeature.tabularFigures()],
                ),
              ),
            ),
          ),
          IconButton(
            onPressed: onDecrement,
            icon: const Icon(Icons.remove, size: 20, color: Colors.white),
            constraints: buttonConstraints,
            padding: EdgeInsets.zero,
          ),
        ],
      ),
    );
  }
}
