import 'dart:convert';

import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:zhiying_comm/zhiying_comm.dart';
import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_bg_notifier.dart';

class MineNavBg extends StatefulWidget {
  final Map<String, dynamic> data;
  Map<String, dynamic> model;

  MineNavBg(this.data, {Key key}) : super(key: key) {
    try {
      model = jsonDecode(data['data']);
    } catch (e, s) {
      Logger.error(e, s);
    }
  }

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

class _MineNavBgState extends State<MineNavBg> {
  int isFirst = 0;

  @override
  void initState() {
    super.initState();
  }

  void _updateBg() {
    final double statusBarHeight = MediaQuery.of(context).padding.top;
    if (widget.model.containsKey('img')) {
      Provider.of<MainPageBgNotifier>(context, listen: false).switchBg(
        Container(
          width: double.infinity,
          height: statusBarHeight + 250,
          child: CachedNetworkImage(
            imageUrl: widget.model['img'],
            fit: BoxFit.fitHeight,
          ),
        ),
      );
    }
  }

  @override
  Widget build(BuildContext context) {
    // Future.delayed(Duration.zero, () {
    //   print("使用" + isFirst.toString());
    //   _updateBg();
    // });
     return Container();
  }
}
