· 6 years ago · Mar 09, 2020, 07:42 AM
1import 'dart:convert';
2import 'dart:io';
3import 'package:commentr/profile/posts_pagination.dart';
4import 'package:commentr/utils/update_profile_image.dart';
5import 'package:image/image.dart' as imageLib;
6import 'package:path/path.dart' as path;
7import 'package:commentr/app_model.dart';
8import 'package:commentr/auth/auth.dart';
9import 'package:commentr/comment_list/comments.dart';
10import 'package:commentr/home/home.dart';
11import 'package:commentr/profile/profile_vm.dart';
12import 'package:commentr/share/share.dart';
13import 'package:commentr/utils/app_colors.dart';
14import 'package:commentr/utils/custom_loader.dart';
15import 'package:dio/dio.dart';
16import 'package:firebase_analytics/firebase_analytics.dart';
17import 'package:firebase_analytics/observer.dart';
18import 'package:firebase_dynamic_links/firebase_dynamic_links.dart';
19import 'package:flutter/cupertino.dart';
20import 'package:flutter/material.dart';
21import 'package:flutter_facebook_login/flutter_facebook_login.dart';
22import 'package:flutter_svg/svg.dart';
23import 'package:font_awesome_flutter/font_awesome_flutter.dart';
24import 'package:google_sign_in/google_sign_in.dart';
25
26import 'package:shared_preferences/shared_preferences.dart';
27import 'package:commentr/utils/err.dart';
28
29import 'edit_profile.dart';
30import 'pagination_comment.dart';
31
32class Profile extends StatefulWidget {
33 GlobalKey<ScaffoldState> sKey;
34 final FirebaseAnalytics analytics;
35 final FirebaseAnalyticsObserver observer;
36
37 Profile({this.observer, this.analytics, this.sKey});
38
39 @override
40 _ProfileState createState() => _ProfileState();
41}
42
43class _ProfileState extends State<Profile> {
44 String userProfileImage;
45 String userId;
46 String userProfileName;
47 ProfileVM pVM;
48 Future<GetProfileModel> gPM;
49
50 GetUserPostModel uPD;
51
52 @override
53 void initState() {
54 // TODO: implement initState
55 super.initState();
56 pVM = ProfileVM();
57 gPM = pVM.getProfileData();
58 initPrefs();
59 }
60
61 initPrefs() async {
62 SharedPreferences prefs = await SharedPreferences.getInstance();
63 userProfileImage = prefs.getString('userImg');
64 userProfileName = prefs.getString('userName');
65 userId = prefs.getString('userId');
66 uPD = await pVM.getUserPost(0,"");
67 setState(() {});
68 }
69
70 final _f_n = TextEditingController();
71
72 bool isHero = true;
73 int tabIndex = 0;
74
75 @override
76 void dispose() {
77 // TODO: implement dispose
78 _f_n.dispose();
79 super.dispose();
80 }
81
82 @override
83 Widget build(BuildContext context) {
84 Future.delayed(const Duration(seconds: 3), () {});
85 return FutureBuilder(
86 future: gPM,
87 initialData: null,
88 builder: (context, snap) => _checkAPIData(context, snap));
89 }
90
91 Widget _checkAPIData(BuildContext c, AsyncSnapshot snap) {
92 //ConnectionState.active = snap.connectionState
93
94 if (snap.hasData && userId != null) {
95 // API
96 // 404
97 // catch
98 GetProfileModel _d = snap.data;
99
100 if (_d.status ?? false) {
101 // API true
102 return userId != null ? _buildList(_d) : _popUpWidget();
103 } else if (_d.is_loading ?? false) {
104 //when clicking retry
105 return CustomLoader(
106 withScaffold: false,
107 );
108 } else {
109 return Err(
110 withScaffold: false,
111 bar_visibility: true,
112 p_title: 'Home',
113 m: (_d.Message == "Check your internet connection" ||
114 _d.Message == null)
115 ? "Check your internet connection"
116 : ("Something went wrong"),
117 mL: () => setState(() {
118 _d.is_loading = true;
119 gPM = pVM.getProfileData();
120 }));
121 }
122 } else if (snap.hasData && userId == null) {
123 return _popUpWidget();
124 } else {
125 // initial loading
126 return CustomLoader(
127 withScaffold: false,
128 );
129 }
130 }
131
132 Widget _popUpWidget() {
133 return Center(
134 child: RaisedButton(
135 onPressed: () {},
136 child: CupertinoAlertDialog(
137 title: Text(
138 "You are not Signed in!",
139 style: TextStyle(fontFamily: 'SanMedium'),
140 ),
141 content: Text(
142 "Sign in now to add a comment.",
143 style: TextStyle(fontFamily: 'SanRegular'),
144 ),
145 actions: <Widget>[
146 CupertinoDialogAction(
147 isDefaultAction: true,
148 child: Text(
149 "Login",
150 style: TextStyle(fontFamily: 'SanBold'),
151 ),
152 onPressed: () {
153 Navigator.push(
154 context,
155 MaterialPageRoute(
156 settings: RouteSettings(name: '/auth'),
157 builder: (builder) => Auth(
158 analytics: widget.analytics,
159 observer: widget.observer,
160 )));
161 },
162 )
163 ],
164 ),
165 ),
166 );
167 }
168
169 UserProfileData uD;
170
171 var refreshKey = GlobalKey<RefreshIndicatorState>();
172
173 Future<Null> refreshList() async {
174 refreshKey.currentState?.show(atTop: false);
175 await Future.delayed(Duration(seconds: 2));
176
177 setState(() {
178 gPM = pVM.getProfileData();
179 });
180
181 return null;
182 }
183
184 Widget _buildList(GetProfileModel d) {
185 final h = MediaQuery.of(context).size.height;
186 final w = MediaQuery.of(context).size.width;
187
188
189
190 uD = d.userProfileList[0];
191 _f_n.text = uD.fullName;
192
193 int textLength = (uD.gotLikeCounts.toString().length + uD.TotalComments.toString().length + uD.totalCommCoins.toString().length);
194
195 return RefreshIndicator(
196 color: Color(0xff323639),
197 onRefresh: refreshList,
198 key: refreshKey,
199 child: Container(
200 height: h,
201// color: Color(0xffece7eb),
202 color: Colors.white,
203 child: ListView(
204 physics: BouncingScrollPhysics(),
205 children: <Widget>[
206 Container(
207// color: Color(0xffece7eb),
208
209 child: Stack(
210 children: <Widget>[
211 Image(
212 image: AssetImage('assets/images/bg.png'),
213 fit: BoxFit.cover,
214 height: 200,
215 ),
216 Padding(
217 padding: const EdgeInsets.fromLTRB(24, 112, 24, 0),
218 child: Card(
219 margin: EdgeInsets.all(0.0),
220 child: Container(
221 padding: EdgeInsets.only(top: 54),
222 height: !uD.isPhone ? 250 : 220,
223 width: w - 48,
224 child: Column(
225 mainAxisAlignment: MainAxisAlignment.spaceBetween,
226 children: <Widget>[
227 Column(
228 children: <Widget>[
229 Padding(
230 padding: const EdgeInsets.only(left: 48),
231 child: Row(
232 mainAxisAlignment: MainAxisAlignment.center,
233 children: <Widget>[
234 Text(
235 uD.fullName,
236 style: TextStyle(
237 fontSize: 18,
238 fontFamily: 'SanRegular',
239 color: Colors.black87),
240 ),
241 Container(
242 height: 30,
243 child: IconButton(
244 icon: Icon(
245 Icons.edit,
246 size: 14,
247 color: Colors.black,
248 ),
249 onPressed: () {
250 _navFun();
251 }))
252 ],
253 ),
254 ),
255 SizedBox(
256 height: 24,
257 ),
258 Container(
259 width: (w - 48) - 48,
260 padding: EdgeInsets.only(top: 8, bottom: 8),
261 decoration: BoxDecoration(
262 border: Border.all(color: Colors.grey)),
263 child: textLength < 15 ? Row(
264 mainAxisAlignment:
265 MainAxisAlignment.spaceEvenly,
266 children: <Widget>[
267 Row(
268 mainAxisAlignment:
269 MainAxisAlignment.center,
270 children: <Widget>[
271 SvgPicture.asset(
272 'assets/images/like.svg',
273 height: 18,
274 fit: BoxFit.cover,
275 color: AppColor.redText,
276 semanticsLabel: 'popup close'),
277 SizedBox(
278 width: 8,
279 ),
280 Text(
281 uD.gotLikeCounts.toString() ?? "",
282 style: TextStyle(
283 fontSize: 16,
284 fontWeight: FontWeight.bold,
285 fontFamily: 'SanBold'),
286 )
287 ],
288 ),
289 Container(
290 width: 0.5,
291 height: 24,
292 color: Colors.grey,
293 ),
294 Row(
295 mainAxisAlignment:
296 MainAxisAlignment.center,
297 children: <Widget>[
298 SvgPicture.asset(
299 'assets/images/comment.svg',
300 height: 18,
301 fit: BoxFit.cover,
302 color: AppColor.redText,
303 semanticsLabel: 'popup close'),
304 SizedBox(
305 width: 8,
306 ),
307 Text(
308 uD.TotalComments.toString() ?? "",
309 style: TextStyle(
310 fontSize: 16,
311 fontWeight: FontWeight.bold,
312 fontFamily: 'SanBold'),
313 )
314 ],
315 ),
316 Container(
317 width: 0.5,
318 height: 24,
319 color: Colors.grey,
320 ),
321 Row(
322 mainAxisAlignment:
323 MainAxisAlignment.center,
324 children: <Widget>[
325 Image(
326 height: 20,
327 image: new AssetImage(
328 'assets/images/g2.png',
329 ),
330 ),
331 SizedBox(
332 width: 8,
333 ),
334 Text(
335 uD.totalCommCoins.toString() ?? "",
336 style: TextStyle(
337 fontSize: 16,
338 fontWeight: FontWeight.bold,
339 fontFamily: 'SanBold'),
340 )
341 ],
342 )
343 ],
344 ):
345 FittedBox(
346 fit: BoxFit.fitWidth,
347 child: Row(
348 mainAxisAlignment:
349 MainAxisAlignment.spaceEvenly,
350 children: <Widget>[
351 Row(
352 mainAxisAlignment:
353 MainAxisAlignment.center,
354 children: <Widget>[
355 SvgPicture.asset(
356 'assets/images/like.svg',
357 height: 18,
358 fit: BoxFit.cover,
359 color: AppColor.redText,
360 semanticsLabel: 'popup close'),
361 SizedBox(
362 width: 8,
363 ),
364 Text(
365 uD.gotLikeCounts.toString() ?? "",
366 style: TextStyle(
367 fontSize: 16,
368 fontWeight: FontWeight.bold,
369 fontFamily: 'SanBold'),
370 )
371 ],
372 ),
373 Container(
374 width: 0.5,
375 height: 24,
376 color: Colors.grey,
377 ),
378 Row(
379 mainAxisAlignment:
380 MainAxisAlignment.center,
381 children: <Widget>[
382 SvgPicture.asset(
383 'assets/images/comment.svg',
384 height: 18,
385 fit: BoxFit.cover,
386 color: AppColor.redText,
387 semanticsLabel: 'popup close'),
388 SizedBox(
389 width: 8,
390 ),
391 Text(
392 uD.TotalComments.toString() ?? "",
393 style: TextStyle(
394 fontSize: 16,
395 fontWeight: FontWeight.bold,
396 fontFamily: 'SanBold'),
397 )
398 ],
399 ),
400 Container(
401 width: 0.5,
402 height: 24,
403 color: Colors.grey,
404 ),
405 Row(
406 mainAxisAlignment:
407 MainAxisAlignment.center,
408 children: <Widget>[
409 Image(
410 height: 20,
411 image: new AssetImage(
412 'assets/images/g2.png',
413 ),
414 ),
415 SizedBox(
416 width: 8,
417 ),
418 Text(
419 uD.totalCommCoins.toString() ?? "",
420 style: TextStyle(
421 fontSize: 16,
422 fontWeight: FontWeight.bold,
423 fontFamily: 'SanBold'),
424 )
425 ],
426 )
427 ],
428 ),
429 ),
430 )
431 ],
432 ),
433
434 Container(
435 height: 40,
436 color: Colors.transparent,
437 child: Card(
438 margin: EdgeInsets.all(0.0),
439 child: Row(
440 children: <Widget>[
441 Container(
442 decoration: BoxDecoration(
443 color: Colors.black,
444 ),
445 height: 40,
446 width: w * .70 - 24,
447 child: Center(
448 child: Text(
449 "Invite friends for ComCoins",
450 textAlign: TextAlign.center,
451 style: TextStyle(
452 color: Colors.white,
453 fontSize: 15,
454 fontFamily: 'SanRegular'),
455 ),
456 ),
457 ),
458 GestureDetector(
459 onTap: () {
460 getDeepLink(d);
461 },
462 child: Container(
463 decoration: BoxDecoration(
464 color: Colors.red,
465 ),
466 height: 40,
467 width: w * .30 - 24,
468 child: Center(
469 child: Icon(
470 Icons.arrow_forward,
471 color: Colors.white,
472 size: 28,
473 ),
474 ),
475 ),
476 )
477 ],
478 ),
479 ),
480 ),
481
482
483 !uD.isPhone ? Container(
484 height: 40,
485 width: double.infinity,
486 decoration: BoxDecoration(
487 color: Color(0xff323639),
488 borderRadius: BorderRadius.only(bottomLeft: Radius.circular(4), bottomRight: Radius.circular(4))
489 ),
490
491 child: GestureDetector(
492 onTap: () {
493 _navFun();
494 },
495 child: Container(
496 child: Text(
497 "Update your PayTM Number, to receive \nRewards Instantly!",
498 textAlign: TextAlign.center,
499 style: TextStyle(
500 color: Colors.white,
501 fontSize: 14,
502 fontFamily: 'SanRegular'),
503 ),
504 ),
505 ),
506 ): Container(),
507
508 ],
509 ),
510 ),
511 ),
512 ),
513 Positioned(
514 top: 74.0,
515 left: w / 2 - 40,
516 child: Container(
517 child: CircleAvatar(
518 child: userProfileImage != null
519 ? Container(
520 decoration: BoxDecoration(
521 borderRadius: BorderRadius.circular(50),
522 border:
523 Border.all(width: 2, color: Colors.white),
524 image: DecorationImage(
525 image: NetworkImage(userProfileImage),
526 fit: BoxFit.cover),
527 ))
528 : Container(
529 padding: EdgeInsets.all(8.0),
530 decoration: BoxDecoration(
531 borderRadius: BorderRadius.circular(50),
532 color: Colors.white,
533 image: DecorationImage(
534 image: NetworkImage(
535 'https://api.capshun.co/assets/icons/comm_icons/userIcon.png',
536 ),
537 fit: BoxFit.cover),
538 )),
539 backgroundColor: Colors.transparent,
540 ),
541 height: 80,
542 width: 80,
543 )),
544 Positioned(
545 top: 128,
546 left: w * .50 + 20,
547 child: GestureDetector(
548 onTap: () {
549 _navFun();
550 },
551 child: Container(
552 decoration: BoxDecoration(
553 color: Colors.black,
554 borderRadius:
555 BorderRadius.all(Radius.circular(50)),
556 border: Border.all(color: Colors.white)),
557 child: Icon(
558 Icons.add,
559 color: Colors.white,
560 size: 18,
561 ))),
562 ),
563 ],
564 ),
565 ),
566 Container(
567 decoration: BoxDecoration(
568 border: Border.all(color: Colors.grey),
569 borderRadius: BorderRadius.all(Radius.circular(4))),
570 margin: EdgeInsets.all(24.0),
571 height: 50,
572 child: Center(
573 child: Row(
574 mainAxisAlignment: MainAxisAlignment.center,
575 children: <Widget>[
576 SvgPicture.asset('assets/images/comment.svg',
577 height: 18,
578 fit: BoxFit.cover,
579 color: tabIndex == 0 ? AppColor.redText : Colors.grey,
580 semanticsLabel: 'popup close'),
581 Container(
582 width: 110,
583// color: Colors.green,
584 child: FlatButton(
585 splashColor: Colors.transparent,
586 padding: EdgeInsets.all(0.0),
587 onPressed: () {
588 setState(() {
589 tabIndex = 0;
590 });
591 },
592 child: Text(
593 "COMMENTS",
594 style: TextStyle(
595 fontSize: 14,
596 fontFamily: 'SanMedium',
597 color: tabIndex == 0
598 ? AppColor.redText
599 : Colors.grey),
600 ),
601 ),
602 ),
603 /* VerticalDivider(),
604 Icon(
605 FontAwesomeIcons.arrowUp,
606 size: 18,
607 color: tabIndex == 1 ? AppColor.redText : Colors.grey,
608 ),
609 Container(
610 width: 96,
611// color: Colors.green,
612 child: FlatButton(
613 splashColor: Colors.transparent,
614 padding: EdgeInsets.all(0.0),
615 onPressed: () {
616 setState(() {
617 tabIndex = 1;
618 });
619 },
620 child: Text(
621 "UPLOADS",
622 style: TextStyle(
623 fontSize: 14,
624 fontFamily: 'SanMedium',
625 color: tabIndex == 1
626 ? AppColor.redText
627 : Colors.grey),
628 )),
629 )*/
630 ],
631 ),
632 ),
633 ),
634 /* tabIndex == 0
635 ? */(uD.commentsAtPosts.length > 0
636 ? Container(
637 child: GridView.count(
638 crossAxisCount: 2,
639// childAspectRatio: devicePixelRatio == 2.625 ? (0.56) : (0.509),
640 childAspectRatio: 1.5,
641 controller:
642 new ScrollController(keepScrollOffset: false),
643 shrinkWrap: true,
644 padding: EdgeInsets.only(
645 top: 0,
646 ),
647 scrollDirection: Axis.vertical,
648 children: uD.commentsAtPosts.map((_m) {
649 int ind = uD.commentsAtPosts.indexOf(_m);
650 CommentAtPostModel cPD = uD.commentsAtPosts[ind];
651
652 return GestureDetector(
653 onTap: () {
654 Navigator.push(
655 context,
656 PageRouteBuilder(
657 settings: RouteSettings(name: '/comments'),
658 pageBuilder: (c, a1, a2) => Comments(
659 postId: cPD.postId,
660 analytics: widget.analytics,
661 observer: widget.observer,
662 ),
663 transitionsBuilder: (c, anim, a2, child) =>
664 FadeTransition(
665 opacity: anim, child: child),
666 transitionDuration:
667 Duration(milliseconds: 500),
668 ),
669 );
670// Navigator.push(context, MaterialPageRoute(builder: (context)=> Comments(postId: cPD.postId,)));
671 },
672 child: Container(
673 decoration: BoxDecoration(
674 borderRadius: BorderRadius.all(
675 Radius.circular(4.0))),
676 margin: ind % 2 == 0
677 ? EdgeInsets.fromLTRB(24.0, 0, 2, 4)
678 : EdgeInsets.fromLTRB(2, 0, 24, 4),
679 child: Stack(
680 children: <Widget>[
681 ClipRRect(
682 borderRadius: BorderRadius.all(
683 Radius.circular(4.0)),
684 child: Image(
685 image: NetworkImage(cPD.image),
686 fit: BoxFit.cover,
687 width: double.infinity,
688 height: double.maxFinite,
689 )),
690 Opacity(
691 opacity: .50,
692 child: Container(
693 decoration: BoxDecoration(
694 color: Colors.black,
695 border: Border.all(
696 color: Colors.grey),
697 borderRadius: BorderRadius.all(
698 Radius.circular(4.0),
699 )),
700 ),
701 ),
702 Padding(
703 padding: const EdgeInsets.all(8.0),
704 child: Center(
705 child: Text(
706 cPD.text,
707 style:
708 TextStyle(color: Colors.white),
709 ),
710 ),
711 ),
712 Positioned(
713 left: 84,
714 top: 76,
715 child: Container(
716 decoration: BoxDecoration(
717 borderRadius: BorderRadius.all(
718 Radius.circular(15))),
719 width: 60,
720 height: 30,
721 child: RaisedButton(
722 color: Colors.white,
723 onPressed: () {},
724 shape: RoundedRectangleBorder(
725 borderRadius:
726 BorderRadius.circular(
727 15)),
728 child: Row(
729 mainAxisAlignment:
730 MainAxisAlignment.center,
731 children: <Widget>[
732 Text(
733 cPD.likes.toString() ?? 0,
734 style: TextStyle(
735 color: Colors.black,
736 fontSize: 12,
737 fontFamily:
738 'SanRegular'),
739 ),
740 SizedBox(
741 width: 4,
742 ),
743 SvgPicture.asset(
744 'assets/images/like.svg',
745 height: 9,
746 fit: BoxFit.cover,
747 color: Colors.black,
748 semanticsLabel:
749 'popup close')
750 ],
751 )),
752 ),
753 )
754 ],
755 )),
756 );
757 }).toList(),
758 ),
759 )
760 : Padding(
761 padding: EdgeInsets.only(top: 16, bottom: 32),
762 child: Center(
763 child: Text(
764 "No Comments Found",
765 style: TextStyle(
766 fontFamily: 'SanMedium', fontSize: 18),
767 ),
768 ),
769 ))
770 /* : _userPostWidget()*/,
771 /*tabIndex == 0
772 ?*/ (uD.commentsAtPosts.length == 20
773 ? FlatButton(
774 onPressed: () {
775 Navigator.push(
776 context,
777 PageRouteBuilder(
778 settings: RouteSettings(name: '/comments'),
779 pageBuilder: (c, a1, a2) => CommentPagination(
780 isFProfile: 1,
781 analytics: widget.analytics,
782 observer: widget.observer,
783 ),
784 transitionsBuilder: (c, anim, a2, child) =>
785 FadeTransition(opacity: anim, child: child),
786 transitionDuration: Duration(milliseconds: 500),
787 ),
788 );
789 },
790 child: Text("View All"))
791 : Container())
792 /* : (uPD.userPosts.length == 20
793 ? FlatButton(
794 onPressed: () {
795 Navigator.push(
796 context,
797 PageRouteBuilder(
798 settings: RouteSettings(name: '/comments'),
799 pageBuilder: (c, a1, a2) => PostsPagination(
800 isFProfile: 1,
801 analytics: widget.analytics,
802 observer: widget.observer,
803 ),
804 transitionsBuilder: (c, anim, a2, child) =>
805 FadeTransition(opacity: anim, child: child),
806 transitionDuration: Duration(milliseconds: 500),
807 ),
808 );
809 },
810 child: Text("View All"))
811 : Container())*/,
812 Container(
813 padding: EdgeInsets.only(left: 24, right: 24),
814 child: FlatButton(
815 shape: RoundedRectangleBorder(
816 borderRadius: BorderRadius.all(Radius.circular(25.0)),
817 side: BorderSide(color: Colors.grey)),
818 onPressed: () {
819 userId != null ? _logout(context) : _signIn(context);
820 },
821 child: Text(userId != null ? "Logout" : "Login"),
822 ),
823 ),
824 SizedBox(
825 height: 16,
826 ),
827
828 /* Container(
829 height: 50,
830 width: w- 100,
831 color: Colors.grey,
832 )*/
833 ],
834 ),
835 ),
836 );
837 }
838
839 Widget _userPostWidget() {
840 return uPD.userPosts.length > 0
841 ? Container(
842 child: GridView.count(
843 crossAxisCount: 2,
844// childAspectRatio: devicePixelRatio == 2.625 ? (0.56) : (0.509),
845 childAspectRatio: 1.5,
846 controller: new ScrollController(keepScrollOffset: false),
847 shrinkWrap: true,
848 padding: EdgeInsets.only(
849 top: 0,
850 ),
851 scrollDirection: Axis.vertical,
852 children: uPD.userPosts.map((_m) {
853 int ind = uPD.userPosts.indexOf(_m);
854 UserPostData cPD = uPD.userPosts[ind];
855
856 return GestureDetector(
857 onTap: () {
858 if (cPD.isApproved) {
859 Navigator.push(
860 context,
861 PageRouteBuilder(
862 settings: RouteSettings(name: '/comments'),
863 pageBuilder: (c, a1, a2) => Comments(
864 postId: cPD.postId,
865 analytics: widget.analytics,
866 observer: widget.observer,
867 ),
868 transitionsBuilder: (c, anim, a2, child) =>
869 FadeTransition(opacity: anim, child: child),
870 transitionDuration: Duration(milliseconds: 500),
871 ),
872 );
873 } else {
874 final snackBar = SnackBar(
875 content:
876 Text("Your post is under review..."));
877 widget.sKey.currentState.showSnackBar(snackBar);
878 }
879
880// Navigator.push(context, MaterialPageRoute(builder: (context)=> Comments(postId: cPD.postId,)));
881 },
882 child: Container(
883 decoration: BoxDecoration(
884 borderRadius: BorderRadius.all(Radius.circular(4.0))),
885 margin: ind % 2 == 0
886 ? EdgeInsets.fromLTRB(24.0, 0, 2, 4)
887 : EdgeInsets.fromLTRB(2, 0, 24, 4),
888 child: Stack(
889 children: <Widget>[
890 ClipRRect(
891 borderRadius:
892 BorderRadius.all(Radius.circular(4.0)),
893 child: Image(
894 image: NetworkImage(cPD.image ?? ""),
895 fit: BoxFit.cover,
896 width: double.infinity,
897 )),
898 Opacity(
899 opacity: .50,
900 child: Container(
901 decoration: BoxDecoration(
902 color: Colors.black,
903 border: Border.all(color: Colors.grey),
904 borderRadius: BorderRadius.all(
905 Radius.circular(4.0),
906 )),
907 ),
908 ),
909 /* Padding(
910 padding: const EdgeInsets.all(8.0),
911 child: Center(
912 child: Text(
913 cPD.text,
914 style: TextStyle(color: Colors.white),
915 ),
916 ),
917 ),*/
918 /* Positioned(
919 left: 84,
920 top: 76,
921 child: Container(
922 decoration: BoxDecoration(
923 borderRadius: BorderRadius.all(
924 Radius.circular(15))),
925 width: 60,
926 height: 30,
927 child: RaisedButton(
928 color: Colors.white,
929 onPressed: () {},
930 shape: RoundedRectangleBorder(
931 borderRadius:
932 BorderRadius.circular(15)),
933 child: Row(
934 mainAxisAlignment:
935 MainAxisAlignment.center,
936 children: <Widget>[
937 Text(
938 cPD.likes.toString() ?? 0,
939 style: TextStyle(
940 color: Colors.black,
941 fontSize: 12,
942 fontFamily: 'SanRegular'),
943 ),
944 SizedBox(
945 width: 4,
946 ),
947 SvgPicture.asset(
948 'assets/images/like.svg',
949 height: 9,
950 fit: BoxFit.cover,
951 color: Colors.black,
952 semanticsLabel: 'popup close')
953 ],
954 )),
955 ),
956 )*/
957 ],
958 )),
959 );
960 }).toList(),
961 ),
962 )
963 : Padding(
964 padding: EdgeInsets.only(top: 16, bottom: 32),
965 child: Center(
966 child: Text(
967 "No Posts Found",
968 style: TextStyle(fontFamily: 'SanMedium', fontSize: 18),
969 ),
970 ),
971 );
972 }
973
974 void getDeepLink(GetProfileModel d) async {
975 Navigator.push(
976 context,
977 PageRouteBuilder(
978 settings: RouteSettings(name: '/share'),
979 pageBuilder: (c, a1, a2) => SharePage(
980 referralCode: d.referralCode,
981 referralLink: d.referralLink,
982 ),
983 transitionsBuilder: (c, anim, a2, child) =>
984 FadeTransition(opacity: anim, child: child),
985 transitionDuration: Duration(milliseconds: 500),
986 ),
987 );
988 }
989
990 void _signIn(BuildContext context) async {
991 Navigator.push(
992 context,
993 PageRouteBuilder(
994 settings: RouteSettings(name: '/auth'),
995 pageBuilder: (c, a1, a2) => Auth(
996 analytics: widget.analytics,
997 observer: widget.observer,
998 ),
999 transitionsBuilder: (c, anim, a2, child) =>
1000 FadeTransition(opacity: anim, child: child),
1001 transitionDuration: Duration(milliseconds: 500),
1002 ),
1003 );
1004
1005// Navigator.push(context, MaterialPageRoute(builder: (context) => Auth()));
1006 }
1007
1008
1009 void _logout(BuildContext context) async {
1010 SharedPreferences prefs = await SharedPreferences.getInstance();
1011 final code = prefs.getInt('socialLoginCode');
1012
1013 switch (code) {
1014 case 0:
1015 final googleSignIn = new GoogleSignIn();
1016 await googleSignIn.signOut();
1017 break;
1018 case 1:
1019 final facebookLogin = new FacebookLogin();
1020 await facebookLogin.logOut();
1021 break;
1022 }
1023 //facebookLogin.logOut();
1024
1025 await prefs.setBool('isLogedIn', false);
1026 await prefs.setInt('socialLoginCode', -1);
1027 await prefs.setString('userId', null);
1028 await prefs.setString('userImg', null);
1029 await prefs.setString('userName', null);
1030
1031 // Update the state of the app
1032 // ...
1033 // Then close the drawer
1034 Navigator.pushReplacement(
1035 context,
1036 MaterialPageRoute(
1037 settings: RouteSettings(name: '/home'),
1038 builder: (context) => new HomePage(
1039 analytics: widget.analytics,
1040 observer: widget.observer,
1041 )));
1042 //Navigator.pop(context);
1043 }
1044
1045 _navFun() async {
1046 final results = await Navigator.push(
1047 context,
1048 PageRouteBuilder(
1049 settings: RouteSettings(name: '/edit_profile'),
1050 pageBuilder: (c, a1, a2) => EditProfile(observer: widget.observer, analytics: widget.analytics,),
1051 transitionsBuilder: (c, anim, a2, child) =>
1052 FadeTransition(opacity: anim, child: child),
1053 transitionDuration: Duration(milliseconds: 500),
1054 ),
1055 );
1056
1057 if (results != null && results.containsKey('is_done')) {
1058 setState(() {
1059 initPrefs();
1060 refreshList();
1061 });
1062 }
1063 }
1064
1065}