import 'package:flutter/material.dart';
import 'package:twongCustomer/models/index.dart';

class UserInfoPage extends StatefulWidget {
  final UserInfo user;

  UserInfoPage(this.user, {Key key}): super(key: key);

  @override
  State<StatefulWidget> createState() => _UserInfoPageState();
}

class _UserInfoPageState extends State<UserInfoPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("用户信息"),
        centerTitle: true,
      ),
      body: ListView(
        physics: ClampingScrollPhysics(),
        children: [
          _buildAvatar(),
          new Divider(),
          ListTile(
            title: Text('昵称:\t\t' + widget.user.username),
            leading: Icon(Icons.account_circle, color: Colors.deepOrange),
          ),
          new Divider(),
          ListTile(
            title: Text('ID:\t\t' + widget.user.uid.toString()),
            leading: Icon(Icons.account_circle, color: Colors.deepOrange),
          ),
          new Divider(),
        ],
      ),
    );
  }

  Widget _buildAvatar() {
    return Container(
        padding: EdgeInsets.only(top: 4),
        child: ClipRRect(
            borderRadius: BorderRadius.circular(20),
            child: Image.network(widget.user.avator, width: 86, height: 86)
        )
    );
  }
}