
import 'package:flutter/material.dart';
import 'package:twong/config/style.dart';
import 'package:twong/widgets/address_selecter.dart';
import 'package:twong/widgets/app_bar.dart';

class ProductCommentPage extends StatefulWidget {
  final String productId;

  ProductCommentPage(this.productId, {Key key}): super(key: key);

  @override
  State<StatefulWidget> createState() {
    return _ProductCommentPageState(productId);
  }
}

class _ProductCommentPageState extends State<ProductCommentPage> {
  String productId;
  String address = "暂未选择";
  _ProductCommentPageState(this.productId);

  void _choiceAddressDialog() async {
    showModalBottomSheet(
        context: context,
        builder: (BuildContext context) {
          return AddressSelecter(
              onSelected: (province, city, county) {
                print('$province-$city-$county');
                address = '$province-$city-$county';
                setState(() {});
              },
              title: '选择地址',
              selectedColor: Colors.red,
              unselectedColor: Colors.black);
        });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: DAppBar("用户评论"),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Container(
              child: RaisedButton(
                child: Text('选择地址'),
                onPressed: _choiceAddressDialog,
              ),
            ),
            Text(address),
          ],
        ),
      )
    );
  }}