add structure
This commit is contained in:
120
lib/pages/block_list.dart
Normal file
120
lib/pages/block_list.dart
Normal file
@@ -0,0 +1,120 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:fcs/model/user_model.dart';
|
||||
import 'package:fcs/pages/util.dart';
|
||||
import 'package:fcs/theme/theme.dart';
|
||||
import 'package:fcs/vo/popup_menu.dart';
|
||||
import 'package:fcs/vo/user.dart';
|
||||
import 'package:fcs/widget/local_text.dart';
|
||||
import 'package:fcs/widget/popupmenu.dart';
|
||||
import 'package:fcs/widget/progress.dart';
|
||||
|
||||
class BlockList extends StatefulWidget {
|
||||
@override
|
||||
_BlockListState createState() => _BlockListState();
|
||||
}
|
||||
|
||||
class _BlockListState extends State<BlockList> {
|
||||
final double dotSize = 15.0;
|
||||
bool _isLoading = false;
|
||||
PopupMenu selectedChoices = blocklistpopup[0];
|
||||
User user = new User();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var userModel = Provider.of<UserModel>(context);
|
||||
|
||||
return LocalProgress(
|
||||
inAsyncCall: _isLoading,
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
backgroundColor: primaryColor,
|
||||
title: LocalText(context, 'user.block_list',
|
||||
color: Colors.white, fontSize: 20),
|
||||
),
|
||||
body: new ListView.builder(
|
||||
padding: EdgeInsets.only(left: 15, right: 15, top: 15, bottom: 10),
|
||||
shrinkWrap: true,
|
||||
itemCount: userModel.getBlockListUsers().length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return Card(
|
||||
elevation: 10,
|
||||
color: Colors.white,
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: InkWell(
|
||||
onTap: () {},
|
||||
child: new Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 7.0),
|
||||
child: new Row(
|
||||
children: <Widget>[
|
||||
new Padding(
|
||||
padding: new EdgeInsets.symmetric(
|
||||
horizontal: 32.0 - dotSize / 2),
|
||||
child: Image.asset(
|
||||
'assets/block.png',
|
||||
width: 50,
|
||||
height: 50,
|
||||
color: primaryColor,
|
||||
)),
|
||||
new Text(
|
||||
userModel.getBlockListUsers()[index].name ==
|
||||
null
|
||||
? ""
|
||||
: userModel.getBlockListUsers()[index].name,
|
||||
style: new TextStyle(
|
||||
fontSize: 17.0, color: Colors.black),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
PopupMenuButton<PopupMenu>(
|
||||
elevation: 3.2,
|
||||
tooltip: 'This is tooltip',
|
||||
onSelected: _select,
|
||||
itemBuilder: (BuildContext context) {
|
||||
this.user = userModel.getBlockListUsers()[index];
|
||||
return blocklistpopup.map((PopupMenu choice) {
|
||||
return PopupMenuItem<PopupMenu>(
|
||||
value: choice,
|
||||
child: Text(choice.status),
|
||||
);
|
||||
}).toList();
|
||||
})
|
||||
],
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _select(PopupMenu choice) async {
|
||||
selectedChoices = choice;
|
||||
if (choice.index == 1) {
|
||||
showConfirmDialog(context, "user.unblock.confirm", () {
|
||||
_unblock();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
_unblock() async {
|
||||
setState(() {
|
||||
_isLoading = true;
|
||||
});
|
||||
|
||||
try {
|
||||
var userModel = Provider.of<UserModel>(context);
|
||||
await userModel.unblockPhone(this.user.phoneNumber);
|
||||
} catch (e) {
|
||||
showMsgDialog(context, "Error", e.toString());
|
||||
} finally {
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user