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.
91 lines
2.7 KiB
91 lines
2.7 KiB
import 'package:provider/provider.dart';
|
|
import 'package:teso/Classes/TesoUser.dart';
|
|
import 'package:teso/Pages/PageWidgets/Friends/friendTile.dart';
|
|
import 'package:teso/Pages/Sub_Pages/userProfile3P.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:teso/Pages/PageWidgets/Friends/header.dart';
|
|
import 'package:page_transition/page_transition.dart';
|
|
import 'package:teso/providers/user_provider.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
class Friends extends StatefulWidget {
|
|
@override
|
|
_FriendsState createState() => _FriendsState();
|
|
}
|
|
|
|
class _FriendsState extends State<Friends> {
|
|
TextEditingController searchkey;
|
|
List<TesoUser> friendsMain = <TesoUser>[];
|
|
List<TesoUser> friends;
|
|
SharedPreferences prefs;
|
|
|
|
void clearText() {
|
|
setState(() {
|
|
searchkey.clear();
|
|
});
|
|
}
|
|
|
|
@override
|
|
void initState() {
|
|
searchkey = new TextEditingController();
|
|
super.initState();
|
|
}
|
|
|
|
updateList(String name) {
|
|
setState(() {
|
|
friends = friendsMain
|
|
.where((element) =>
|
|
element.username.toLowerCase().contains(name.toLowerCase()))
|
|
.toList();
|
|
friends.sort((a, b) {
|
|
return b.firstname.compareTo(a.firstname);
|
|
});
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
// extendBody: true,
|
|
appBar: PreferredSize(
|
|
preferredSize: Size.fromHeight(90),
|
|
child: buildFriendsHeader(context, searchkey, updateList),
|
|
),
|
|
body: Consumer<UserProvider>(
|
|
builder: (context, value, child) {
|
|
if (value.friends == null) {
|
|
return Center(
|
|
child: CircularProgressIndicator(
|
|
valueColor: AlwaysStoppedAnimation<Color>(
|
|
Theme.of(context).primaryColor)));
|
|
} else {
|
|
if (friendsMain.length == 0) {
|
|
friendsMain = value.friends;
|
|
friends = value.friends;
|
|
}
|
|
friends.sort((a, b) {
|
|
return b.firstname.compareTo(a.firstname);
|
|
});
|
|
return ListView.builder(
|
|
itemCount: friends.length,
|
|
itemBuilder: (context, int index) {
|
|
return InkWell(
|
|
onTap: () => Navigator.push(
|
|
context,
|
|
PageTransition(
|
|
child: UserProfileThirdPerson(
|
|
user: friends.elementAt(index),
|
|
),
|
|
type: PageTransitionType.fade,
|
|
),
|
|
),
|
|
child: buildFriend(context, friends.elementAt(index)),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|