import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';

Color _white = const Color(0xFFFFFFFF);

class LabeledIconButton extends StatelessWidget {
  final String label;
  final IconData iconData;
  final Color? materialColor;
  final Color? cupertinoColor;
  final VoidCallback? onPressed;
  final double? width;

  const LabeledIconButton({
    Key? key,
    required this.label,
    required this.iconData,
    this.materialColor,
    this.cupertinoColor,
    this.width,
    required this.onPressed,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return PlatformWidget(
        key: key,
        material: (_, __) => Container(
            width: width,
            color: materialColor,
            child: PlatformElevatedButton(
                onPressed: onPressed,
                color: materialColor,
                child: Column(children: [
                  Icon(iconData, color: _white),
                  Text(label, style: TextStyle(color: _white))
                ]))),
        cupertino: (_, __) => Container(
              width: width,
              color: cupertinoColor,
              child: PlatformElevatedButton(
                  onPressed: onPressed,
                  color: cupertinoColor,
                  child: Column(children: [
                    Icon(iconData, color: _white),
                    Text(label, style: TextStyle(color: _white))
                  ])),
            ));
  }
}
