You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
172 lines
5.5 KiB
172 lines
5.5 KiB
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:pull_to_refresh/pull_to_refresh.dart';
|
|
import 'package:teso/Classes/TesoUser.dart';
|
|
import 'package:teso/Classes/customTesoButton.dart';
|
|
import 'package:teso/Pages/PageWidgets/Friends/friendTile.dart';
|
|
import 'package:teso/providers/user_provider.dart';
|
|
import 'package:teso/util/SizeConfig.dart';
|
|
import 'package:teso/util/consts.dart';
|
|
|
|
class BlockAccounts extends StatefulWidget {
|
|
const BlockAccounts({Key key}) : super(key: key);
|
|
|
|
@override
|
|
_BlockAccountsState createState() => _BlockAccountsState();
|
|
}
|
|
|
|
class _BlockAccountsState extends State<BlockAccounts> {
|
|
RefreshController _refreshController =
|
|
RefreshController(initialRefresh: false);
|
|
void _onRefresh() async {
|
|
try {
|
|
await Provider.of<UserProvider>(context, listen: false)
|
|
.checkBlockedUsers();
|
|
} catch (e) {
|
|
print(e);
|
|
}
|
|
_refreshController.refreshCompleted();
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_refreshController.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
backgroundColor: Theme.of(context).backgroundColor,
|
|
elevation: 5,
|
|
centerTitle: true,
|
|
title: Text(
|
|
"Blocked Users",
|
|
style: TextStyle(
|
|
fontSize: SizeConfig.blockSizeHorizontal * 3.5,
|
|
color: Colors.red[800],
|
|
),
|
|
),
|
|
),
|
|
body: Consumer<UserProvider>(
|
|
builder: (context, value, child) {
|
|
if (value.blockUserList == null) {
|
|
return Center(
|
|
child: CircularProgressIndicator(
|
|
valueColor: AlwaysStoppedAnimation<Color>(
|
|
Theme.of(context).primaryColor)));
|
|
} else {
|
|
return SmartRefresher(
|
|
enablePullDown: true,
|
|
enablePullUp: false,
|
|
header: ClassicHeader(),
|
|
controller: _refreshController,
|
|
onRefresh: _onRefresh,
|
|
child: ListView.builder(
|
|
itemCount: value.blockUserList.length,
|
|
itemBuilder: (context, int index) {
|
|
return InkWell(
|
|
onTap: () => reportDialog(
|
|
context,
|
|
value.blockUserList.elementAt(index),
|
|
),
|
|
child: Column(
|
|
children: [
|
|
buildFriend(
|
|
context,
|
|
value.blockUserList.elementAt(index),
|
|
),
|
|
Padding(
|
|
padding: EdgeInsets.symmetric(horizontal: 25),
|
|
child: Divider(),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
void reportDialog(BuildContext context, TesoUser user) {
|
|
showModalBottomSheet(
|
|
context: context,
|
|
isScrollControlled: true,
|
|
enableDrag: true,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.vertical(top: Radius.circular(30.0)),
|
|
),
|
|
builder: (BuildContext bc) {
|
|
return Container(
|
|
height: MediaQuery.of(context).size.height * 0.3,
|
|
child: Column(
|
|
children: [
|
|
Container(
|
|
margin: EdgeInsets.only(
|
|
top: 15,
|
|
),
|
|
child: Center(
|
|
child: Text(
|
|
"Unblock ${user.username}?",
|
|
style: TextStyle(
|
|
fontSize: SizeConfig.blockSizeHorizontal * 4.5,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
Container(
|
|
padding: EdgeInsets.symmetric(
|
|
horizontal: 15,
|
|
vertical: 15,
|
|
),
|
|
child: Center(
|
|
child: Text(
|
|
"${user.username} will now be able to request to follow and message you Instagram. "
|
|
"They won't be notified that you unblocked them.",
|
|
style: TextStyle(
|
|
fontSize: SizeConfig.blockSizeHorizontal * 3.5,
|
|
fontWeight: FontWeight.w400,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
Divider(),
|
|
Container(
|
|
margin: EdgeInsets.only(top: 20),
|
|
width: MediaQuery.of(context).size.width - 40,
|
|
height: 40,
|
|
child: RaisedGradientButton(
|
|
child: Text(
|
|
"Unblock",
|
|
style: TextStyle(color: Colors.white, fontSize: 18),
|
|
),
|
|
gradient: LinearGradient(
|
|
begin: Alignment.topCenter,
|
|
end: Alignment.bottomCenter,
|
|
colors: [
|
|
tesoBlue,
|
|
Colors.blueAccent,
|
|
],
|
|
),
|
|
onPressed: () {
|
|
Provider.of<UserProvider>(context, listen: false)
|
|
.unblockUser(user);
|
|
Navigator.pop(context);
|
|
},
|
|
width: MediaQuery.of(context).size.width - 40,
|
|
height: 40,
|
|
),
|
|
)
|
|
],
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|
|
|