import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:get/get_core/src/get_main.dart';

class MoneyCard extends StatefulWidget {
  final bool type;
  const MoneyCard({Key? key, this.type = false}) : super(key: key);

  @override
  State<MoneyCard> createState() => _MoneyCardState();
}

class _MoneyCardState extends State<MoneyCard> {
  void _goWithdrawPage() {
    print('asdasdsad');
    Get.toNamed('/withdrawal');
  }

  @override
  Widget build(BuildContext context) {
    if (!widget.type) {
      return Container(
        width: 345.w,
        height: 173.w,
        padding: EdgeInsets.fromLTRB(40, 33, 0, 0),
        alignment: Alignment.centerLeft,
        decoration: BoxDecoration(
          borderRadius: new BorderRadius.all(new Radius.circular(20.0)),
          image: const DecorationImage(
            image: AssetImage(
              'images/main/walletBgi.png',
            ),
          ),
        ),
        child: Column(
          children: [
            Text(
              '钱包余额(元)',
              style: TextStyle(fontSize: 20.sp, color: Colors.white),
            ),
            Container(
              margin: EdgeInsets.fromLTRB(0, 20, 0, 10),
              child: Text(
                (5 / 100).toString(),
                style: TextStyle(
                  fontSize: 35.sp,
                  color: Colors.white,
                  fontWeight: FontWeight.bold,
                ),
              ),
            ),
            GestureDetector(
              onTap: () {
                _goWithdrawPage();
              },
              child: Container(
                alignment: Alignment.center,
                width: 70.w,
                height: 34.w,
                decoration: BoxDecoration(
                  borderRadius: BorderRadius.circular(20),
                  gradient: LinearGradient(


                    begin: Alignment.topCenter,
                    end: Alignment.bottomCenter,
                    colors: [
                      Color(0xff37BC6A),
                      Color(0xff127B39),
                    ],
                  ),
                ),
                child: Text(
                  '提现',
                  style: TextStyle(
                    fontSize: 24.sp,
                    color: Colors.white,
                    fontWeight: FontWeight.bold,
                  ),
                ),
              ),
            )
          ],
        ),
      );
    } else {
      return _initWidget();
    }
  }
}

class _initWidget extends StatelessWidget {
  const _initWidget({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      width: 345.w,
      height: 173.w,
      padding: EdgeInsets.fromLTRB(40, 33, 0, 0),
      alignment: Alignment.centerLeft,
      decoration: BoxDecoration(
        borderRadius: new BorderRadius.all(new Radius.circular(20.0)),
        image: const DecorationImage(
          image: AssetImage(
            'images/main/walletBgi.png',
          ),
        ),
      ),
      child: Column(
        children: [
          Text(
            '钱包余额(元)',
            style: TextStyle(fontSize: 20.sp, color: Colors.white),
          ),
          Container(
            margin: EdgeInsets.fromLTRB(0, 20, 0, 10),
            child: Text(
              (5 / 100).toString(),
              style: TextStyle(
                fontSize: 35.sp,
                color: Colors.white,
                fontWeight: FontWeight.bold,
              ),
            ),
          ),
        ],
      ),
    );
  }
}
