import 'package:flutter/material.dart';

import '../../tools/YSColors.dart';
import '../../tools/YSNetWork.dart';
import '../../tools/YSTools.dart';

class YSPriceView extends StatefulWidget {
  final Map item;
  const YSPriceView({Key? key, required this.item}) : super(key: key);

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

class YSPriceViewState extends State<YSPriceView> {
  Map _info = {};
  @override
  void initState() {
    networkDelay((){
      _getInfoData();
    });
    super.initState();
  }
  _getInfoData() async{
    YSNetWork.ysRequestHttp(context, type: RequestType.get, api: 'market24hr', parameter: {'symbol':widget.item['symbol']}, successSetter: (dict){
      List list = dict['data']['list']??[];
      if(list.isNotEmpty){
        _info = list.first;
        setState(() {});
      }
    });
  }
  @override
  Widget build(BuildContext context) {
    return Text(_info.isNotEmpty?_info['lastPrice']:'',style: YSColors.subStyle(context),);
  }
}
