
import 'package:flutter/material.dart';
import 'package:twong/router/base.dart';

import 'package:twong/utils/index.dart';
import 'package:twong/config/style.dart';
import 'package:twong/widgets/app_bar.dart';

class SettingPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _SettingPageState();
  }
}
class _SettingPageState extends State<SettingPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: DAppBar("设置"),
      body: SafeArea(
        child: ListView(
          children: [
            _buildLogout()
          ],
        ),
      ),
    );
  }

  Widget _buildLogout () {
    return Container(
      padding: EdgeInsets.all(16),
      child: FlatButton(
        color: DColors.Main,
        shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(20))),
        onPressed: () {
          Utils.showAlert(context, title: "确定退出登陆？", ok: () {
            Cache.clearAll();
            Navigator.pop(context);
            Navigator.popAndPushNamed(context, RouteNames.home);
          });
        },
        child: Text('退出登录', style: TextStyle(color: Colors.white)),
      ),
    );
  }
}