import 'package:flutter/material.dart';

class SecurityCodeButton extends StatelessWidget {
  final String title;
  final VoidCallback onSend;
  final Color color;
  final bool enabled;

  const SecurityCodeButton(
    this.title, {
    Key key,
    this.onSend,
    this.enabled = true,
    this.color = const Color(0xffff4242),
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      child: Container(
        width: 72,
        height: 26,
        decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(13),
          border: Border.all(
            width: 0.5,
            color: enabled ? color : Color(0xff999999),
          ),
        ),
        child: Center(
          child: Text(
            title ?? '获取验证码',
            style: TextStyle(
              fontSize: 10,
              color: enabled ? color : Color(0xff999999),
            ),
          ),
        ),
      ),
      onTap: () {
        if (enabled && onSend != null) {
          onSend();
        }
      },
    );
  }
}
