import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter/widgets.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:netrain_flutter_app/douwen/custom/BaseView.dart';
import 'package:netrain_flutter_app/douwen/custom/BaseViewModel.dart';
import 'package:netrain_flutter_app/douwen/custom/http/AdService.dart';

import 'custom/http/base/IEntity.dart';

class Demo2 extends BaseView {
  Demo2() : super(BaseViewModel());


  _item(String title, VoidCallback onPressed) {
    return Container(
      child: RaisedButton(
        onPressed: onPressed,
        child: Text(title),
      ),
    );
  }

  @override
  Widget builder(BuildContext context, BaseViewModel value, Widget child) {
    Container(
        child: Column(
          children: [
            Row(
              children: [
                _item("setNormal", () {
                  viewModel.setNormal();
                }),
                _item("setEmpty", () {
                  viewModel.setEmpty();
                }),
                _item("setError", () {
                  viewModel.setError();
                }),
              ],
            ),
            setReplaceView(Row(
              children: [
                ValueListenableBuilder(
                    valueListenable: viewModel.showText,
                    builder: (context, value, child) =>
                        Text(value.toString())),
                ElevatedButton(
                    onPressed: () async {
                      viewModel.login();
                    },
                    child: Text("点击"))
              ],
            )),
          ],
        )
    );
  }
}
