Created
October 2, 2020 19:24
-
-
Save mulieriq/af231ad26266c1a8c344e6baa1ef00f8 to your computer and use it in GitHub Desktop.
......
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Author : Eng.Muli Eric | |
Project : The Epistles Fellowhip Mobile App | |
Platform : Mobile Application | |
Technology : Flutter | |
Target : Android And IoS Os | |
Date : Mon May 27th 2019 22:34:30 | |
Page Title : Home Page | |
*/ | |
import 'dart:async'; | |
import 'dart:convert'; | |
import 'dart:core'; | |
import 'package:cached_network_image/cached_network_image.dart'; | |
import 'package:cloud_firestore/cloud_firestore.dart'; | |
import 'package:fab_circular_menu/fab_circular_menu.dart'; | |
import 'package:firebase_messaging/firebase_messaging.dart'; | |
import 'package:flutter/cupertino.dart'; | |
import 'package:flutter/material.dart'; | |
import 'package:flutter_staggered_animations/flutter_staggered_animations.dart'; | |
import 'package:font_awesome_flutter/font_awesome_flutter.dart'; | |
import 'package:intl/intl.dart'; | |
import 'package:mccu_family/controllers/core/scoped.dart'; | |
import 'package:mccu_family/global/globasl.dart'; | |
import 'package:mccu_family/ui/chat/broadcast/index.dart'; | |
import 'package:mccu_family/ui/chat/main.dart'; | |
import 'package:mccu_family/ui/chat/secure/pickup_Layout.dart'; | |
import 'package:mccu_family/ui/chat/secure/privateChat.dart'; | |
import 'package:mccu_family/ui/event/events.dart'; | |
import 'package:mccu_family/ui/event/notifications.dart'; | |
import 'package:mccu_family/ui/leaders/dashboard.dart'; | |
import 'package:mccu_family/ui/leaders/leaders.dart'; | |
import 'package:mccu_family/ui/post/posts.dart'; | |
import 'package:mccu_family/ui/profile/member_list.dart'; | |
import 'package:mccu_family/ui/profile/members_profile.dart'; | |
import 'package:mccu_family/ui/systemadmin/mass_analysis.dart'; | |
import 'package:passcode_screen/circle.dart'; | |
import 'package:passcode_screen/keyboard.dart'; | |
import 'package:passcode_screen/passcode_screen.dart'; | |
import 'package:permission_handler/permission_handler.dart'; | |
import 'package:scoped_model/scoped_model.dart'; | |
import 'package:share/share.dart'; | |
import 'package:toast/toast.dart' as prefix0; | |
import 'package:toast/toast.dart'; | |
import 'about.dart'; | |
import 'addPost.dart'; | |
class HomePage extends StatefulWidget { | |
final String uid; | |
final String username; | |
final String role; | |
final String email; | |
final String phonenumber; | |
final String collage; | |
final String year; | |
final String status; | |
final String family; | |
final String userImage; | |
final String birthday; | |
HomePage( | |
{this.uid, | |
this.username, | |
this.birthday, | |
this.status, | |
this.userImage, | |
this.role, | |
this.email, | |
this.phonenumber, | |
this.collage, | |
this.year, | |
this.family}); | |
@override | |
_HomePageState createState() => _HomePageState(); | |
} | |
class _HomePageState extends State<HomePage> { | |
final FirebaseMessaging _firebaseMessaging = FirebaseMessaging(); | |
final _text = TextEditingController(); | |
final StreamController<bool> _verificationNotifier = | |
StreamController<bool>.broadcast(); | |
void dispose() { | |
_text.dispose(); | |
_verificationNotifier.close(); | |
} | |
bool isLike = false; | |
bool _validate = false; | |
String comment; | |
int chatLenth = 0; | |
bool isAuthenticated = false; | |
getnumberOfMessage() async { | |
Firestore.instance | |
.collection('message') | |
.document(widget.uid) | |
.collection('convo') | |
.where("receiveruid", isEqualTo: widget.uid) | |
.getDocuments() | |
.then(((r) { | |
setState(() { | |
chatLenth = r.documents.length; | |
print('${chatLenth.toString()} _______________________Chat Length'); | |
}); | |
})); | |
} | |
_showLockScreen(BuildContext context, | |
{bool opaque, | |
CircleUIConfig circleUIConfig, | |
KeyboardUIConfig keyboardUIConfig}) { | |
Navigator.push( | |
context, | |
PageRouteBuilder( | |
opaque: opaque, | |
pageBuilder: (context, animation, secondaryAnimation) => | |
PasscodeScreen( | |
passwordDigits: 7, | |
title: '*Danger Zone*', | |
titleColor: Colors.red, | |
circleUIConfig: circleUIConfig, | |
keyboardUIConfig: keyboardUIConfig, | |
passwordEnteredCallback: _onPasscodeEntered, | |
cancelLocalizedText: 'Cancel', | |
deleteLocalizedText: 'Delete', | |
shouldTriggerVerification: _verificationNotifier.stream, | |
backgroundColor: Colors.black.withOpacity(0.8), | |
cancelCallback: _onPasscodeCancelled, | |
), | |
)); | |
} | |
_onPasscodeEntered(String enteredPasscode) { | |
bool isValid = "${passkey[2].toString()}899" == enteredPasscode; | |
print("${passkey[2].toString()}899"); | |
_verificationNotifier.add(isValid); | |
if (isValid) { | |
setState(() { | |
this.isAuthenticated = isValid; | |
}); | |
Navigator.pop(context); | |
} | |
} | |
List passkey = []; | |
Future getpasskey() async { | |
passkey.clear(); | |
return await Firestore.instance | |
.collection("msvssecure") | |
.getDocuments() | |
.then((results) { | |
results.documents.forEach((data) { | |
passkey.add(data.data["pass"]); | |
print(passkey.toString()); | |
}); | |
// print(results.documents); | |
}); | |
} | |
_onPasscodeCancelled() {} | |
void postLike(String postId, String uid) { | |
var _like = { | |
"ownerName": widget.username, | |
"ownerPhotoUrl": widget.userImage, | |
"ownerUid": widget.uid, | |
"timeStamp": FieldValue.serverTimestamp() | |
}; | |
Firestore.instance | |
.collection('posts') | |
.document(postId) | |
.collection('likes') | |
.document(uid) | |
.setData(_like) | |
.then((r) { | |
print('liked'); | |
}); | |
} | |
void postUnlike(String postId, String uid) { | |
Firestore.instance | |
.collection('likes') | |
.document(postId) | |
.collection('likes') | |
.document(uid) | |
.delete() | |
.then((r) { | |
print('deleted'); | |
}); | |
} | |
Future checkIfUserLikedOrNot( | |
String postId, | |
String uid, | |
) async { | |
return StreamBuilder( | |
stream: Firestore.instance | |
.collection("posts") | |
.document(postId) | |
.collection('likes') | |
.document(uid) | |
.snapshots(), | |
builder: (BuildContext context, snapshot) { | |
if (snapshot.hasData != null) { | |
setState(() { | |
isLike = true; | |
}); | |
} else { | |
setState(() { | |
isLike = false; | |
}); | |
} | |
}, | |
); | |
} | |
@override | |
Widget bodyBuild() { | |
return ScopedModelDescendant<Scoped>( | |
builder: (BuildContext context, Widget child, Scoped model) { | |
return PickupLayout( | |
scaffold: SafeArea( | |
child: StreamBuilder<QuerySnapshot>( | |
stream: Firestore.instance | |
.collection('posts') | |
.orderBy('time', descending: true) | |
.snapshots(), | |
builder: (BuildContext context, snapshot) { | |
if (snapshot.hasError) { | |
print(snapshot.error); | |
} else if (snapshot.connectionState == ConnectionState.none) { | |
return Center( | |
child: Text("Please Check Your Internet Connetion ..."), | |
); | |
} else if (snapshot.hasData) { | |
return RefreshIndicator( | |
onRefresh: model.getpullData, | |
child: ListView.builder( | |
addAutomaticKeepAlives: true, | |
physics: AlwaysScrollableScrollPhysics(), | |
itemCount: snapshot.data.documents.length, | |
itemBuilder: (context, i) { | |
//checkIfUserLikedOrNot(snapshot.data.documents[i].documentID, widget.uid); | |
Firestore.instance | |
.collection("posts") | |
.document(snapshot.data.documents[i].documentID) | |
.collection('likes') | |
.snapshots() | |
.contains(widget.uid) | |
.then((r) { | |
setState(() { | |
isLike = true; | |
}); | |
}).catchError((e) { | |
setState(() { | |
isLike = false; | |
}); | |
}); | |
return AnimationLimiter( | |
child: Column( | |
children: AnimationConfiguration.toStaggeredList( | |
duration: const Duration(milliseconds: 975), | |
childAnimationBuilder: (widget) => SlideAnimation( | |
horizontalOffset: 50.0, | |
child: FadeInAnimation( | |
child: widget, | |
), | |
), | |
children: [ | |
Container( | |
decoration: BoxDecoration( | |
borderRadius: | |
BorderRadius.circular(2.0)), | |
child: InkWell( | |
onLongPress: () { | |
if (snapshot.data.documents[i] | |
.data['senderId'] == | |
widget.uid) { | |
Toast.show("Post Deleted", context); | |
return Firestore.instance | |
.collection("posts") | |
.document( | |
snapshot.data.documents[i] | |
.documentID, | |
) | |
.delete(); | |
} | |
}, | |
onTap: () => Navigator.of(context).push( | |
CupertinoPageRoute( | |
builder: (BuildContext context) => Post( | |
uid: widget.uid, | |
uName: widget.username, | |
userImage: widget.userImage, | |
postId: snapshot.data | |
.documents[i].documentID, | |
username: snapshot | |
.data | |
.documents[i] | |
.data['username'], | |
time: snapshot | |
.data | |
.documents[i] | |
.data['time'], | |
category: snapshot | |
.data | |
.documents[i] | |
.data['category'], | |
title: snapshot | |
.data | |
.documents[i] | |
.data['title'], | |
imgUrl: snapshot | |
.data | |
.documents[i] | |
.data['imgUrl'], | |
senderImage: snapshot.data.documents[i].data['userImage'], | |
story: snapshot.data.documents[i].data['post']))), | |
child: Card( | |
clipBehavior: Clip.hardEdge, | |
child: Container( | |
// margin: EdgeInsets.all(6.0), | |
child: new Column( | |
children: <Widget>[ | |
ListTile( | |
// leading: new CircleAvatar( | |
// backgroundImage: NetworkImage( | |
// snapshot.data.documents[i] | |
// .data['userImage']), | |
// ), | |
title: new CustomTextTitle( | |
incomingText: snapshot | |
.data | |
.documents[i] | |
.data['username'], | |
//textScaleFactor: 1.0, | |
color: BLACK_COLOR, | |
), | |
trailing: new CustomTextSmall( | |
text: DateFormat( | |
"E dd MMM y kk:mm") | |
.format(DateTime | |
.fromMillisecondsSinceEpoch( | |
int.parse(snapshot | |
.data | |
.documents[i] | |
.data['time']))), | |
color: BLACK_COLOR, | |
), | |
), | |
// Divider( | |
// indent: 70, | |
// height: 3, | |
// ), | |
Container( | |
child: | |
snapshot.data.documents[i] | |
.data[ | |
'imgUrl'] == | |
null | |
? null | |
: new Container( | |
height: MediaQuery.of( | |
context) | |
.size | |
.height * | |
.3, | |
width: | |
MediaQuery.of( | |
context) | |
.size | |
.width, | |
child: Hero( | |
flightShuttleBuilder: | |
null, | |
transitionOnUserGestures: | |
true, | |
tag: snapshot | |
.data | |
.documents[ | |
i] | |
.documentID, | |
child: | |
Container( | |
child: CachedNetworkImage( | |
fit: BoxFit.cover, | |
fadeInCurve: Curves.easeInOutCirc, | |
fadeInDuration: Duration(seconds: 2), | |
fadeOutCurve: Curves.easeInOutCirc, | |
fadeOutDuration: Duration(seconds: 2), | |
imageUrl: snapshot.data.documents[i].data['imgUrl'], | |
useOldImageOnUrlChange: true, | |
placeholder: (context, url) => Image.asset( | |
"lib/assets/loader.gif", | |
), | |
errorWidget: (context, url, error) => Image.asset( | |
"lib/assets/mcculogo.png", | |
fit: BoxFit.cover, | |
)), | |
)), | |
)), | |
ListTile( | |
contentPadding: | |
EdgeInsets.all(0), | |
title: Padding( | |
padding: EdgeInsets.only( | |
left: | |
MediaQuery.of(context) | |
.size | |
.width * | |
.03), | |
child: Text( | |
snapshot.data.documents[i] | |
.data['title'] | |
.toString() | |
.toUpperCase(), | |
style: TextStyle( | |
fontWeight: | |
FontWeight.bold, | |
fontSize: 17), | |
overflow: TextOverflow.clip, | |
), | |
), | |
subtitle: Row( | |
mainAxisAlignment: | |
MainAxisAlignment | |
.spaceBetween, | |
children: <Widget>[ | |
Row( | |
mainAxisAlignment: | |
MainAxisAlignment | |
.spaceEvenly, | |
children: <Widget>[ | |
IconButton( | |
iconSize: 20, | |
icon: Icon( | |
FontAwesomeIcons | |
.commentDots, | |
color: Colors | |
.blueAccent), | |
onPressed: () { | |
return showModalBottomSheet( | |
shape: RoundedRectangleBorder( | |
borderRadius: | |
BorderRadius.all(Radius.circular( | |
10.0))), | |
context: | |
context, | |
builder: | |
(BuildContext | |
ccontext) { | |
return SingleChildScrollView( | |
child: Container( | |
height: MediaQuery.of(context).size.height * 0.6, | |
child: Padding( | |
padding: | |
EdgeInsets.all(20), | |
child: | |
Column( | |
mainAxisAlignment: | |
MainAxisAlignment.start, | |
mainAxisSize: | |
MainAxisSize.max, | |
children: <Widget>[ | |
Text('Add Comment '), | |
TextField( | |
controller: _text, | |
onChanged: (value) { | |
setState(() { | |
comment = value; | |
}); | |
}, | |
maxLines: 1, | |
decoration: InputDecoration(errorText: _validate ? 'Value can\'t Be Empty' : null, hintText: 'Not More Than 10 lines...', labelText: 'Comment'), | |
), | |
RaisedButton( | |
onPressed: () { | |
setState(() { | |
_text.text.isEmpty ? _validate = true : _validate = false; | |
}); | |
if (comment == null) { | |
prefix0.Toast.show("Comment Cant Be Empty", context); | |
} else { | |
Map<String, dynamic> comments = { | |
'senderName': widget.username, | |
'senderId': widget.uid, | |
'senderImg': widget.userImage, | |
'sendTime': DateTime.now().millisecondsSinceEpoch.toString(), | |
'comment': comment | |
}; | |
Firestore.instance.collection('posts').document(snapshot.data.documents[i].documentID).collection('comments').add(comments).then((result) { | |
prefix0.Toast.show("Comment Sent", context); | |
// dispose(); | |
}).catchError((e) { | |
prefix0.Toast.show("Comment Not Sent", context); | |
}); | |
print(jsonEncode(comments)); | |
Navigator.pop(context); | |
} | |
}, | |
shape: StadiumBorder(), | |
child: Text('Send'), | |
color: Colors.amberAccent, | |
) | |
], | |
), | |
)), | |
); | |
}); | |
}, | |
), | |
IconButton( | |
iconSize: 20, | |
icon: Icon( | |
FontAwesomeIcons | |
.share, | |
color: Colors | |
.amberAccent), | |
onPressed: () async { | |
Share.share(snapshot | |
.data | |
.documents[ | |
i] | |
.data[ | |
'title'] + | |
"\n" + | |
snapshot | |
.data | |
.documents[ | |
i] | |
.data[ | |
'post'] + | |
"\n" + | |
snapshot | |
.data | |
.documents[ | |
i] | |
.data[ | |
'username'] + | |
"\n\n The Epistles Family"); | |
}, | |
), | |
IconButton( | |
iconSize: 20, | |
icon: Icon( | |
Icons.thumb_up, | |
color: Colors.green, | |
), | |
onPressed: () async { | |
Firestore.instance | |
.collection( | |
'likes') | |
.document(snapshot | |
.data | |
.documents[ | |
i] | |
.documentID) | |
.collection( | |
'likes') | |
.document( | |
widget.uid) | |
.setData({ | |
'likerImage': | |
widget | |
.userImage, | |
'likerName': | |
widget | |
.username, | |
'likerRole': widget | |
.role | |
.toUpperCase() | |
}).then((r) { | |
Toast.show( | |
'Liked', | |
context); | |
}).catchError((e) { | |
Toast.show( | |
'You Already Liked This Post', | |
context); | |
}); | |
}, | |
), | |
IconButton( | |
icon: Icon( | |
Icons.thumb_down, | |
color: Colors.red, | |
), | |
onPressed: () { | |
Firestore.instance | |
.collection( | |
'likes') | |
.document(snapshot | |
.data | |
.documents[ | |
i] | |
.documentID) | |
.collection( | |
'likes') | |
.document( | |
widget.uid) | |
.delete() | |
.then((r) { | |
Toast.show( | |
'Post DisLiked', | |
context); | |
}).catchError((e) { | |
Toast.show( | |
'You Already DisLiked This Post', | |
context); | |
}); | |
}, | |
), | |
// SizedBox( | |
// width: MediaQuery.of( | |
// context) | |
// .size | |
// .width * | |
// 2 / | |
// 10, | |
// ), | |
], | |
) | |
], | |
), | |
trailing: Container( | |
padding: EdgeInsets.only( | |
top: MediaQuery.of(context) | |
.size | |
.height * | |
.032, | |
right: | |
MediaQuery.of(context) | |
.size | |
.width * | |
.03, | |
), | |
child: StreamBuilder( | |
stream: Firestore.instance | |
.collection('likes') | |
.document(snapshot | |
.data | |
.documents[i] | |
.documentID) | |
.collection('likes') | |
.snapshots(), | |
builder: | |
(BuildContext context, | |
snap) { | |
if (snap.hasData && | |
snap.data.documents | |
.length == | |
0) { | |
return Text('0 Likes'); | |
} else if (snap | |
.connectionState == | |
ConnectionState | |
.none) { | |
return Text('0 Likes'); | |
} else if (snap.hasData) { | |
return SafeArea( | |
child: InkWell( | |
child: Text( | |
"${snap.data.documents.length} Likes", | |
overflow: | |
TextOverflow | |
.ellipsis), | |
onTap: () { | |
return showModalBottomSheet( | |
shape: RoundedRectangleBorder( | |
borderRadius: | |
BorderRadius.all(Radius.circular( | |
10.0))), | |
context: | |
context, | |
builder: | |
(BuildContext | |
ccontext) { | |
return ListView | |
.builder( | |
itemCount: snap | |
.data | |
.documents | |
.length, | |
itemBuilder: | |
(context, | |
index) { | |
return ListTile( | |
title: Text(snap | |
.data | |
.documents[index] | |
.data['likerName']), | |
subtitle: Text(snap | |
.data | |
.documents[index] | |
.data['likerRole']), | |
); | |
}, | |
); | |
}); | |
}, | |
), | |
); | |
} else if (snap | |
.connectionState != | |
ConnectionState | |
.done) { | |
return Text( | |
'0 Likes', | |
overflow: TextOverflow | |
.ellipsis, | |
); | |
} else if (!snap | |
.hasData) { | |
return Text('0 Likes', | |
overflow: | |
TextOverflow | |
.ellipsis); | |
} else if (!snap | |
.hasData && | |
snap.connectionState == | |
ConnectionState | |
.done) { | |
return Text('0 Likes', | |
overflow: | |
TextOverflow | |
.ellipsis); | |
} | |
}, | |
), | |
), | |
) | |
// Column( | |
// crossAxisAlignment: | |
// CrossAxisAlignment.start, | |
// children: <Widget>[ | |
// Container( | |
// padding: | |
// EdgeInsets.only(top: 5), | |
// child: | |
// ), | |
// //changes from firebase starts from here | |
// ], | |
// ), | |
], | |
), | |
), | |
), | |
)), | |
], | |
), | |
), | |
); | |
}), | |
// ), | |
); | |
} else if (snapshot.connectionState != ConnectionState.done) { | |
return Center( | |
child: CircularProgressIndicator(), | |
); | |
} else if (!snapshot.hasData) { | |
return Text('0 Likes', overflow: TextOverflow.ellipsis); | |
} else if (!snapshot.hasData && | |
snapshot.connectionState == ConnectionState.done) { | |
return Text('0 Likes', overflow: TextOverflow.ellipsis); | |
} | |
}, | |
), | |
), | |
); | |
}); | |
} | |
@override | |
void initState() { | |
_handleCameraAndMic(); | |
_firebaseMessaging.subscribeToTopic('posts'); | |
_firebaseMessaging.subscribeToTopic('announcments'); | |
_firebaseMessaging.subscribeToTopic('updates'); | |
_firebaseMessaging.subscribeToTopic('events'); | |
_firebaseMessaging.getToken().then((r) { | |
print( | |
'${r} token from home ________________________________________________home'); | |
}); | |
getnumberOfMessage(); | |
super.initState(); | |
} | |
_handleCameraAndMic() async { | |
await PermissionHandler().requestPermissions([ | |
PermissionGroup.camera, | |
PermissionGroup.microphone, | |
PermissionGroup.location, | |
PermissionGroup.speech | |
]); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return ScopedModelDescendant<Scoped>( | |
builder: (BuildContext context, Widget child, Scoped model) { | |
return Scaffold( | |
appBar: new AppBar( | |
elevation: 0.5, | |
centerTitle: true, | |
title: new Text( | |
'Loged In As ${widget.username.split(' ')[0]}', | |
style: TextStyle( | |
fontWeight: FontWeight.w600, | |
fontFamily: 'BilboSwashCaps', | |
fontSize: 25, | |
color: Colors.green), | |
), | |
actions: <Widget>[ | |
Stack( | |
children: <Widget>[ | |
IconButton( | |
icon: Icon(FontAwesomeIcons.sms), | |
onPressed: () { | |
Navigator.push( | |
context, | |
CupertinoPageRoute( | |
builder: (context) => PrivateChat( | |
role: model.role, | |
family: widget.family, | |
authId: widget.uid, | |
senderImage: widget.userImage, | |
senderName: widget.username, | |
))); | |
}, | |
), | |
Container( | |
child: chatLenth > 0 | |
? Positioned( | |
top: MediaQuery.of(context).size.height * 0.0095, | |
left: MediaQuery.of(context).size.width * 0.065, | |
child: CircleAvatar( | |
radius: 7.0, | |
backgroundColor: Colors.green, | |
), | |
) | |
: Positioned( | |
top: MediaQuery.of(context).size.height * 0.00, | |
left: MediaQuery.of(context).size.width * 0.00, | |
child: CircleAvatar( | |
radius: 0.0, | |
backgroundColor: Colors.green, | |
), | |
)) | |
], | |
) | |
], | |
), | |
floatingActionButton: FabCircularMenu( | |
ringWidth: 50, | |
ringDiameter: 225, | |
ringColor: Colors.transparent, | |
// ringColor: Colors.white, | |
// ringDiameter: 20, | |
children: <Widget>[ | |
FloatingActionButton( | |
tooltip: "About", | |
heroTag: "info", | |
child: Icon(Icons.info), | |
backgroundColor: Colors.orangeAccent, | |
onPressed: () { | |
Navigator.push( | |
context, | |
CupertinoPageRoute( | |
builder: (BuildContext context) => About())); | |
}), | |
FloatingActionButton( | |
tooltip: "Leaders", | |
heroTag: "role", | |
child: Icon(FontAwesomeIcons.criticalRole), | |
backgroundColor: Colors.black, | |
onPressed: () { | |
Navigator.push( | |
context, | |
CupertinoPageRoute( | |
builder: (BuildContext context) => Leaders())); | |
}), | |
FloatingActionButton( | |
tooltip: "Add Post", | |
heroTag: "add", | |
child: Icon(Icons.add), | |
backgroundColor: Colors.blue, | |
onPressed: () { | |
Navigator.push( | |
context, | |
CupertinoPageRoute( | |
builder: (BuildContext context) => AddPost())); | |
}), | |
]), | |
body: RefreshIndicator( | |
onRefresh: model.getpullData, child: bodyBuild()), | |
drawer: SafeArea( | |
child: Drawer( | |
child: SingleChildScrollView( | |
child: Column( | |
children: <Widget>[ | |
Container( | |
// height: MediaQuery.of(context).size.height * .25, | |
child: UserAccountsDrawerHeader( | |
currentAccountPicture: CircleAvatar( | |
radius: MediaQuery.of(context).size.width * .2, | |
backgroundImage: | |
AssetImage("lib/assets/mcculogo.png"), | |
), | |
accountName: Text("MCCU Families"), | |
accountEmail: Text("Home Away From Home")), | |
), | |
ListTile( | |
title: Text('Video Conferencing', | |
overflow: TextOverflow.ellipsis), | |
leading: Icon(FontAwesomeIcons.video), | |
onTap: () { | |
Navigator.pop(context); | |
Navigator.push( | |
context, | |
CupertinoPageRoute( | |
builder: (context) => VideoConfrence( | |
username: widget.username.split(" ")[0]))); | |
}, | |
), | |
// ListTile( | |
// title: Text('Map', overflow: TextOverflow.ellipsis), | |
// leading: Icon(FontAwesomeIcons.video), | |
// onTap: () { | |
// Navigator.pop(context); | |
// Navigator.push( | |
// context, | |
// CupertinoPageRoute( | |
// builder: (context) => MapSample( | |
// lat: -1.280423, | |
// long: 36.816311, | |
// ))); | |
// }, | |
// ), | |
ListTile( | |
title: Text('Live Stream', overflow: TextOverflow.ellipsis), | |
leading: Icon(FontAwesomeIcons.wifi), | |
onTap: () { | |
Navigator.pop(context); | |
Navigator.push( | |
context, | |
CupertinoPageRoute( | |
builder: (context) => IndexPage())); | |
}, | |
), | |
ListTile( | |
title: Text('Chats', overflow: TextOverflow.ellipsis), | |
leading: Icon(FontAwesomeIcons.sms), | |
onTap: () { | |
Navigator.pop(context); | |
Navigator.push( | |
context, | |
CupertinoPageRoute( | |
builder: (context) => PrivateChat( | |
role: model.role, | |
family: widget.family, | |
authId: widget.uid, | |
senderImage: widget.userImage, | |
senderName: widget.username, | |
))); | |
}, | |
), | |
Divider(), | |
ListTile( | |
title: Text('Profile', overflow: TextOverflow.ellipsis), | |
leading: Icon(FontAwesomeIcons.userTie), | |
onTap: () { | |
Navigator.pop(context); | |
Navigator.push( | |
context, | |
CupertinoPageRoute( | |
builder: (context) => MembersPage( | |
authId: widget.uid, | |
uid: widget.uid, | |
userImage: widget.userImage, | |
username: widget.username, | |
role: model.role, | |
status: widget.status, | |
phonenumber: widget.phonenumber, | |
collage: widget.collage, | |
year: widget.year, | |
family: widget.family, | |
birthday: widget.birthday, | |
))); | |
}, | |
), | |
ListTile( | |
title: Text('Members', overflow: TextOverflow.ellipsis), | |
leading: Icon(FontAwesomeIcons.users), | |
onTap: () { | |
Navigator.pop(context); | |
Navigator.push( | |
context, | |
CupertinoPageRoute( | |
builder: (context) => MembersList( | |
family: widget.family, | |
authId: widget.uid, | |
))); | |
}, | |
), | |
Container( | |
child: model.role.toLowerCase() == "system admin" || | |
model.role.toLowerCase() == "secretary" || | |
model.role.toLowerCase().contains("mentor") || | |
model.role.toLowerCase().contains("overseer") || | |
model.role.toLowerCase() == "treasurer" || | |
model.role.toLowerCase() == "chairperson" || | |
model.role.toLowerCase() == "vice chairperson" || | |
model.role.toLowerCase().contains("worship") || | |
model.role.toLowerCase().contains("prayer") || | |
model.role.toLowerCase().contains("calebs") || | |
model.role.toLowerCase().contains("queens") | |
? ListTile( | |
title: Text(model.role.toUpperCase(), | |
overflow: TextOverflow.ellipsis), | |
leading: Icon(FontAwesomeIcons.criticalRole), | |
onTap: () { | |
Navigator.pop(context); | |
Navigator.push( | |
context, | |
CupertinoPageRoute( | |
builder: (context) => Dashboard( | |
family: widget.family, | |
uid: widget.uid, | |
username: widget.username, | |
imgurl: widget.userImage, | |
role: model?.role, | |
))); | |
}, | |
) | |
: Container()), | |
model.role.toLowerCase() == "system admin" | |
? ListTile( | |
title: Text('MSVS', | |
style: TextStyle(color: Colors.red), | |
overflow: TextOverflow.ellipsis), | |
leading: Icon( | |
FontAwesomeIcons.radiation, | |
color: Colors.red, | |
), | |
onTap: () { | |
Navigator.pop(context); | |
Navigator.push( | |
context, | |
CupertinoPageRoute( | |
builder: (context) => MassAnalysis( | |
authId: widget.uid, | |
))); | |
// isAuthenticated | |
// ? Navigator.push( | |
// context, | |
// CupertinoPageRoute( | |
// builder: (context) => MassAnalysis( | |
// authId: widget.uid, | |
// ))) | |
// : getpasskey().then((r) { | |
// _showLockScreen(context, | |
// opaque: false, | |
// circleUIConfig: CircleUIConfig( | |
// borderColor: Colors.red, | |
// fillColor: Colors.red, | |
// circleSize: 30), | |
// keyboardUIConfig: KeyboardUIConfig( | |
// digitBorderWidth: 2, | |
// primaryColor: Colors.red)); | |
// }); | |
}, | |
) | |
: Container(), | |
Divider(), | |
ListTile( | |
title: Text('Announcment', overflow: TextOverflow.ellipsis), | |
leading: Icon(Icons.announcement), | |
onTap: () { | |
Navigator.pop(context); | |
Navigator.push( | |
context, | |
CupertinoPageRoute( | |
builder: (context) => Notifications( | |
family: widget.family, | |
uid: widget.uid, | |
userName: widget.username, | |
))); | |
}, | |
), | |
ListTile( | |
title: Text('Events', overflow: TextOverflow.ellipsis), | |
leading: Icon(Icons.event_available), | |
onTap: () { | |
Navigator.pop(context); | |
Navigator.push( | |
context, | |
CupertinoPageRoute( | |
builder: (context) => Events( | |
username: widget.username, | |
))); | |
}, | |
), | |
Divider(), | |
ListTile( | |
title: Text('Logout', overflow: TextOverflow.ellipsis), | |
leading: Icon(FontAwesomeIcons.signOutAlt), | |
onTap: () async { | |
model.signOut(context); | |
return Firestore.instance | |
.collection('users') | |
.document(widget.uid) | |
.updateData({ | |
"state": "Offline", | |
'lastseen': FieldValue.serverTimestamp() | |
}); | |
}, | |
), | |
], | |
), | |
), | |
)), | |
); | |
}, | |
); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (img == null) { | |
return showToast( | |
"Kindly Provide An Image", | |
Colors.red); | |
} else { | |
if (_formKey.currentState.validate()) { | |
if (yearFellowship == "Select Family") { | |
showToast( | |
"Please Provide Your Fellowship", | |
Colors.red); | |
} else { | |
if (phoneSanitizer) { | |
setState(() { | |
upload = true; | |
if (img != null) { | |
uploadImage() | |
.then((result) async { | |
print("uploded image"); | |
print(imgUrlDownload); | |
SharedPreferences | |
autoAuthToken = | |
await SharedPreferences | |
.getInstance(); | |
autoAuthToken.setString( | |
'emailToken', | |
widget.userEmail); | |
autoAuthToken.setString( | |
"status", | |
"Hey there,I am using MCCU Families app"); | |
autoAuthToken.setString( | |
'username', | |
widget.userName); | |
autoAuthToken.setString( | |
'role', 'Member'); | |
autoAuthToken.setString( | |
'uid', widget.uid); | |
autoAuthToken.setString( | |
'year', | |
yearFellowship == | |
"Associates" | |
? "Cleared School" | |
: currentyear, | |
); | |
autoAuthToken.setString( | |
'userImage', | |
imgUrlDownload); | |
autoAuthToken.setString( | |
'birthday', birthday); | |
autoAuthToken.setString( | |
'collage', | |
yearFellowship == | |
"Associates" | |
? "Cleared School" | |
: currentyear, | |
); | |
autoAuthToken.setString( | |
'phoneNumber', | |
"$countrycode$phoneNumber", | |
); | |
autoAuthToken.setString( | |
'family', | |
yearFellowship, | |
); | |
if (imgUrlDownload != null) { | |
addData({ | |
'status': | |
"Hey there,I am using MCCU Families app", | |
'userPhoneNumber': | |
"$countrycode$phoneNumber", | |
'userId': widget.uid, | |
'userEmail': | |
widget.userEmail, | |
'userName': | |
widget.userName, | |
'userImage': | |
imgUrlDownload, | |
'role': "member", | |
'family': yearFellowship | |
.toLowerCase(), | |
"isleader": false, | |
'userBio': { | |
'family': | |
yearFellowship, | |
'year': yearFellowship == | |
"Associates" | |
? "Cleared School" | |
: currentyear, | |
'birthday': birthday, | |
'collage': | |
yearFellowship == | |
"Associates" | |
? "Cleared School" | |
: collage, | |
}, | |
'verified': { | |
'verification': true, | |
'message': '', | |
'logout': false | |
}, | |
'deviceInfo': { | |
'userName': | |
widget.userName, | |
'userId': widget.uid, | |
'androidId': androidInfo | |
.androidId, | |
'board': | |
androidInfo.board, | |
'bootloader': | |
androidInfo | |
.bootloader, | |
'brand': | |
androidInfo.brand, | |
'device': | |
androidInfo.device, | |
'display': | |
androidInfo.display, | |
'fingerprint': | |
androidInfo | |
.fingerprint, | |
'hardware': androidInfo | |
.hardware, | |
'hashCode': androidInfo | |
.hashCode, | |
'host': | |
androidInfo.host, | |
'id': androidInfo.id, | |
'isPhysicalDevice': | |
androidInfo | |
.isPhysicalDevice, | |
'manufacturer': | |
androidInfo | |
.manufacturer, | |
'mode': | |
androidInfo.model, | |
'product': | |
androidInfo.product, | |
}, | |
'pushToken': tokens, | |
}).then((result) { | |
print( | |
"data was added success fully"); | |
model.setdeviceInfo( | |
userName: | |
widget.userName, | |
userid: widget.uid); | |
model.role = "Member"; | |
model.status = status; | |
Navigator.of(context) | |
.pushReplacement( | |
MaterialPageRoute( | |
builder: | |
(BuildContext | |
context) => | |
App( | |
uid: | |
widget.uid, | |
phonenumber: | |
"$countrycode$phoneNumber", | |
email: | |
widget.userEmail, | |
status: | |
"Hey there,I am using MCCU Families app", | |
username: | |
widget.userName, | |
userImage: | |
imgUrlDownload, | |
family: | |
yearFellowship, | |
role: | |
"Member", | |
year: yearFellowship == "Associates" | |
? "Cleared School" | |
: currentyear, | |
birthday: | |
birthday, | |
collage: | |
collage, | |
))); | |
}).catchError((e) { | |
print(e); | |
}); | |
} else { | |
setState(() { | |
upload = false; | |
}); | |
return Toast.show( | |
"Didnt get img Url", | |
context); | |
//print('didnt get img url'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:cached_network_image/cached_network_image.dart'; | |
import 'package:flutter/cupertino.dart'; | |
import 'package:flutter/material.dart'; | |
import 'package:scoped_model/scoped_model.dart'; | |
import 'package:url_launcher/url_launcher.dart'; | |
import '../../controllers/core/scoped.dart'; | |
import '../../global/globasl.dart'; | |
import 'profile_edit.dart'; | |
class MembersPage extends StatefulWidget { | |
final authId; //user | |
final String username; | |
final String uid; //from db | |
final String role; | |
final String status; | |
final String phonenumber; | |
final String collage; | |
final String year; | |
final String family; | |
final String userImage; | |
final String birthday; | |
MembersPage( | |
{this.username, | |
this.authId, | |
this.birthday, | |
this.userImage, | |
this.uid, | |
this.role, | |
this.status, | |
this.phonenumber, | |
this.collage, | |
this.year, | |
this.family}); | |
@override | |
_MembersPageState createState() => _MembersPageState(); | |
} | |
class _MembersPageState extends State<MembersPage> { | |
@override | |
Widget build(BuildContext context) { | |
return ScopedModelDescendant( | |
builder: (BuildContext context, Widget child, Scoped model) { | |
return Scaffold( | |
body: SafeArea( | |
child: CustomScrollView( | |
slivers: <Widget>[ | |
SliverAppBar( | |
actions: <Widget>[ | |
Container( | |
child: widget.authId == widget.uid | |
? IconButton( | |
icon: Icon(Icons.edit), | |
onPressed: () => Navigator.push( | |
context, | |
CupertinoPageRoute( | |
builder: (context) => EditProfileScreen( | |
uid: widget.uid, | |
authId: widget.authId, | |
userImage: widget.userImage, | |
username: widget.username, | |
role: widget.role, | |
status: model.status, | |
phonenumber: widget.phonenumber, | |
collage: widget.collage, | |
year: widget.year, | |
family: widget.family, | |
birthday: widget.birthday, | |
))), | |
) | |
: Container()) | |
], | |
automaticallyImplyLeading: false, | |
leading: GestureDetector( | |
child: Icon(Icons.arrow_back_ios), | |
onTap: () => Navigator.pop(context), | |
), | |
pinned: true, | |
floating: false, | |
expandedHeight: MediaQuery.of(context).size.height * .45, | |
elevation: 1, | |
forceElevated: true, | |
flexibleSpace: FlexibleSpaceBar( | |
background: new Container( | |
width: MediaQuery.of(context).size.width, | |
child: Hero( | |
tag: 'image', | |
child: CachedNetworkImage( | |
fit: BoxFit.cover, | |
fadeInCurve: Curves.easeInOutCirc, | |
fadeInDuration: Duration(seconds: 2), | |
fadeOutCurve: Curves.easeInOutCirc, | |
fadeOutDuration: Duration(seconds: 2), | |
imageUrl: widget.userImage != null | |
? widget.userImage | |
: "lib/assets/loader.gif", | |
useOldImageOnUrlChange: true, | |
placeholder: (context, url) => Image.asset( | |
"lib/assets/loader.gif", | |
), | |
errorWidget: (context, url, error) => Image.asset( | |
"lib/assets/noimage.png", | |
fit: BoxFit.cover, | |
) | |
// child: FadeInImage.assetNetwork( | |
// , | |
// image: widget.userImage == null | |
// ? 'lib/assets/wait.jpg' | |
// : widget.userImage, | |
// placeholder: 'lib/assets/wait.jpg', | |
// fit: BoxFit.fitWidth, | |
// ), | |
), | |
)), | |
title: new Text( | |
widget.username, | |
style: TextStyle(fontFamily: 'BilboSwashCaps', fontSize: 23), | |
), | |
), | |
), | |
SliverList( | |
delegate: SliverChildListDelegate([ | |
Container( | |
decoration: BoxDecoration( | |
gradient: LinearGradient(colors: [ | |
Colors.greenAccent.withOpacity(0.05), | |
Colors.blueAccent.withOpacity(0.3) | |
], begin: Alignment.topLeft, end: Alignment.bottomRight)), | |
child: Column( | |
crossAxisAlignment: CrossAxisAlignment.start, | |
children: <Widget>[ | |
Padding( | |
padding: const EdgeInsets.all(8.0), | |
child: CustomTextTitle( | |
incomingText: "Personal Info", color: Colors.blue), | |
), | |
// | |
Card( | |
elevation: 5, | |
child: Container( | |
decoration: BoxDecoration( | |
gradient: LinearGradient( | |
colors: [ | |
Colors.greenAccent.withOpacity(0.05), | |
Colors.greenAccent.withOpacity(0.7) | |
], | |
begin: Alignment.topLeft, | |
end: Alignment.bottomRight)), | |
child: Column( | |
crossAxisAlignment: CrossAxisAlignment.start, | |
children: <Widget>[ | |
Padding( | |
padding: const EdgeInsets.all(8.0), | |
child: Row( | |
crossAxisAlignment: CrossAxisAlignment.start, | |
children: <Widget>[ | |
Column( | |
crossAxisAlignment: | |
CrossAxisAlignment.start, | |
children: <Widget>[ | |
CustomTextTitle( | |
incomingText: "Name:", | |
color: BLACK_COLOR), | |
CustomTextTitle( | |
incomingText: widget.username, | |
color: Colors.grey) | |
], | |
) | |
], | |
), | |
), | |
Padding( | |
padding: const EdgeInsets.all(8.0), | |
child: Row( | |
children: <Widget>[ | |
Column( | |
crossAxisAlignment: | |
CrossAxisAlignment.start, | |
children: <Widget>[ | |
CustomTextTitle( | |
incomingText: "Status", | |
color: BLACK_COLOR), | |
CustomTextModified( | |
alignment: TextAlign.justify, | |
text: widget.authId == widget.uid | |
? model.status | |
: widget.status, | |
color: GREY_COLOR) | |
], | |
) | |
], | |
), | |
), | |
InkWell( | |
onTap: () async { | |
await launch("tel:${widget.phonenumber}"); | |
}, | |
child: Row( | |
children: <Widget>[ | |
Padding( | |
padding: const EdgeInsets.all(8.0), | |
child: Column( | |
crossAxisAlignment: | |
CrossAxisAlignment.start, | |
children: <Widget>[ | |
CustomTextTitle( | |
incomingText: "Phone Number:", | |
color: BLACK_COLOR), | |
CustomTextTitle( | |
incomingText: widget.phonenumber, | |
color: GREY_COLOR) | |
], | |
), | |
) | |
], | |
), | |
) | |
], | |
), | |
), | |
// ), | |
), | |
Padding( | |
padding: const EdgeInsets.all(8.0), | |
child: CustomTextTitle( | |
incomingText: "School Info", color: Colors.blue), | |
), | |
// | |
Card( | |
elevation: 5, | |
// child: | |
//Padding( | |
// padding: const EdgeInsets.all(8.0), | |
child: Container( | |
decoration: BoxDecoration( | |
gradient: LinearGradient( | |
colors: [ | |
Colors.greenAccent.withOpacity(0.05), | |
Colors.greenAccent.withOpacity(0.7) | |
], | |
begin: Alignment.topLeft, | |
end: Alignment.bottomRight)), | |
child: Column( | |
crossAxisAlignment: CrossAxisAlignment.start, | |
children: <Widget>[ | |
Padding( | |
padding: const EdgeInsets.all(8.0), | |
child: Row( | |
crossAxisAlignment: CrossAxisAlignment.start, | |
children: <Widget>[ | |
Column( | |
crossAxisAlignment: | |
CrossAxisAlignment.start, | |
children: <Widget>[ | |
CustomTextTitle( | |
incomingText: "Collage:", | |
color: BLACK_COLOR), | |
CustomTextTitle( | |
incomingText: widget.collage, | |
color: Colors.grey) | |
], | |
) | |
], | |
), | |
), | |
Padding( | |
padding: const EdgeInsets.all(8.0), | |
child: Row( | |
children: <Widget>[ | |
Column( | |
crossAxisAlignment: | |
CrossAxisAlignment.start, | |
children: <Widget>[ | |
CustomTextTitle( | |
incomingText: "Year:", | |
color: BLACK_COLOR), | |
CustomTextTitle( | |
incomingText: widget.year, | |
color: GREY_COLOR) | |
], | |
) | |
], | |
), | |
), | |
InkWell( | |
child: Row( | |
children: <Widget>[ | |
Padding( | |
padding: const EdgeInsets.all(8.0), | |
child: Column( | |
crossAxisAlignment: | |
CrossAxisAlignment.start, | |
children: <Widget>[ | |
CustomTextTitle( | |
incomingText: "Year Fellowhip:", | |
color: BLACK_COLOR), | |
CustomTextTitle( | |
incomingText: widget.family, | |
color: GREY_COLOR) | |
], | |
), | |
) | |
], | |
), | |
) | |
], | |
), | |
), | |
// ), | |
), | |
Padding( | |
padding: const EdgeInsets.all(8.0), | |
child: CustomTextTitle( | |
incomingText: "Account Info", color: Colors.blue), | |
), | |
// | |
Card( | |
elevation: 5, | |
child: Container( | |
decoration: BoxDecoration( | |
gradient: LinearGradient( | |
colors: [ | |
Colors.greenAccent.withOpacity(0.05), | |
Colors.greenAccent.withOpacity(0.7) | |
], | |
begin: Alignment.topLeft, | |
end: Alignment.bottomRight)), | |
child: Column( | |
children: <Widget>[ | |
ListTile( | |
title: CustomTextTitle( | |
incomingText: 'Role', | |
color: BLACK_COLOR, | |
), | |
subtitle: CustomTextTitle( | |
incomingText: widget.role.toUpperCase(), | |
color: GREY_COLOR, | |
), | |
) | |
], | |
), | |
), | |
), | |
Container( | |
height: MediaQuery.of(context).size.height * 0.01) | |
], | |
), | |
) | |
// //collage | |
// //Role | |
]), | |
) | |
], | |
), | |
)); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment