import 'package:flutter/material.dart';
import 'package:flutter_wallet/tools/YSSqflite.dart';

import '../../base/YSBase.dart';
import '../../tools/YSTools.dart';
import 'YSWalletListItemView.dart';

class YSWalletMineTokenChoose extends StatefulWidget {
  const YSWalletMineTokenChoose({Key? key}) : super(key: key);

  @override
  YSWalletMineTokenChooseState createState() => YSWalletMineTokenChooseState();
}

class YSWalletMineTokenChooseState extends State<YSWalletMineTokenChoose> {
  List _dataArray = [];
  @override
  void initState() {
    networkDelay((){
      _getTokenData();
    });
    super.initState();
  }
  _getTokenData()async{
    _dataArray = await YSSqflite2().init().rawQuery();
    setState(() {});
  }
  @override
  Widget build(BuildContext context) {
    return YSBase(
      ysTitle: '资产',
      ysChild: SizedBox(
        height: ysHeight(context),
        width: ysWidth(context),
        child: ListView.builder(
          itemBuilder: (context, index) {
            Map item = _dataArray[index];
            return YSWalletListChooseItemView(item: item,valueSetter: (value){
              Navigator.of(context).pop(value);
            },);
          },
          itemCount: _dataArray.length,
          padding: const EdgeInsets.all(0),
          shrinkWrap: true,
          physics: const NeverScrollableScrollPhysics(),
        ),
      ),
    );
  }
}
