Created
May 13, 2020 22:16
-
-
Save huxaiphaer/e141b87b65b21bf3b2ef8626375b8913 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
| import 'dart:convert'; | |
| import 'dart:developer'; | |
| import 'package:flutter/cupertino.dart'; | |
| import 'package:flutter/material.dart'; | |
| import 'package:flutter_svg/flutter_svg.dart'; | |
| import 'package:newvisionapp/src/models/authentication/google_auth_response.dart'; | |
| import 'package:newvisionapp/src/models/more_categories/more_category_model.dart'; | |
| import 'package:newvisionapp/src/resources/local_providers/profile_preference_provider.dart'; | |
| import 'package:newvisionapp/src/ui/home/home.dart'; | |
| import 'package:newvisionapp/src/ui/profile/edit_profile.dart'; | |
| import 'package:provider/provider.dart'; | |
| import 'package:shared_preferences/shared_preferences.dart'; | |
| class ProfilePage extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) { | |
| final bloc = Provider.of<PreferenceProvider>(context).bloc; | |
| return Scaffold( | |
| body: CustomScrollView( | |
| slivers: <Widget>[ | |
| SliverAppBar( | |
| expandedHeight: 200, | |
| floating: true, | |
| pinned: true, | |
| snap: true, | |
| elevation: 10.0, | |
| title: Text('Profile'), | |
| flexibleSpace: FlexibleSpaceBar( | |
| background: StreamBuilder<AuthResponse>( | |
| stream: bloc.user, | |
| builder: (context, snapshot) { | |
| return Container( | |
| margin: EdgeInsets.only(top: 100.0, left: 20.0), | |
| child: Column( | |
| crossAxisAlignment: CrossAxisAlignment.start, | |
| children: <Widget>[ | |
| CircleAvatar( | |
| radius: 30.0, | |
| backgroundImage: AssetImage('assets/profile_pic.png'), | |
| ), | |
| SizedBox( | |
| height: 10, | |
| ), | |
| Row( | |
| mainAxisAlignment: MainAxisAlignment.spaceBetween, | |
| children: <Widget>[ | |
| Text( | |
| '${snapshot.data.user.firstName == null ? "" : snapshot.data.user.firstName} ${snapshot.data.user.lastName == null ? "" : snapshot.data.user.lastName}', | |
| style: TextStyle( | |
| color: Colors.white, | |
| fontSize: 14.0, | |
| fontWeight: FontWeight.bold, | |
| letterSpacing: 0.1, | |
| ), | |
| ), | |
| GestureDetector( | |
| onTap: () { | |
| Navigator.push( | |
| context, | |
| MaterialPageRoute( | |
| builder: (context) => EditProfile()), | |
| ); | |
| }, | |
| child: Container( | |
| width: 100, | |
| padding: EdgeInsets.all(6.0), | |
| child: Text( | |
| 'EDIT PROFILE', | |
| textWidthBasis: TextWidthBasis.longestLine, | |
| style: TextStyle( | |
| color: Color(0xFFFAFAFA), | |
| fontSize: 10.0, | |
| fontWeight: FontWeight.w700, | |
| letterSpacing: 1.5, | |
| ), | |
| ), | |
| decoration: BoxDecoration( | |
| color: const Color( | |
| 0xFFD2232A, | |
| ), | |
| boxShadow: [ | |
| BoxShadow( | |
| color: Colors.black.withOpacity(0.3), | |
| spreadRadius: 1, | |
| blurRadius: 1, | |
| offset: Offset( | |
| 0, 1), // changes position of shadow | |
| ), | |
| ], | |
| borderRadius: BorderRadius.only( | |
| topLeft: Radius.circular(5), | |
| bottomLeft: Radius.circular(5)), | |
| ), | |
| ), | |
| ), | |
| ], | |
| ), | |
| SizedBox( | |
| height: 5, | |
| ), | |
| Text( | |
| '${snapshot.data.user.email == null ? "" : snapshot.data.user.email}', | |
| style: TextStyle( | |
| color: Colors.white, | |
| fontSize: 14.0, | |
| fontWeight: FontWeight.w300, | |
| letterSpacing: 0.1, | |
| ), | |
| ), | |
| SizedBox( | |
| height: 5, | |
| ), | |
| ], | |
| ), | |
| ); | |
| }, | |
| ), | |
| ), | |
| ), | |
| Container( | |
| child: _profileDetails(), | |
| ) | |
| ], | |
| ), | |
| ); | |
| } | |
| Widget _profileDetails() { | |
| return SliverList( | |
| delegate: SliverChildListDelegate([ | |
| _journalists(), | |
| MoreCategoriesPlaceHolder(), | |
| _notifications(), | |
| SizedBox( | |
| height: 20.0, | |
| ), | |
| _termsOfService(), | |
| SizedBox( | |
| height: 20.0, | |
| ), | |
| ]), | |
| ); | |
| } | |
| Widget _notifications() { | |
| return Column( | |
| children: <Widget>[ | |
| Row(children: <Widget>[ | |
| Container( | |
| margin: EdgeInsets.only(left: 30.0), | |
| child: Text('Notifications', | |
| textAlign: TextAlign.start, | |
| style: TextStyle( | |
| fontSize: 14.0, | |
| color: Colors.black, | |
| fontWeight: FontWeight.bold, | |
| )), | |
| ), | |
| ]), | |
| Container( | |
| margin: EdgeInsets.all(18.0), | |
| child: Divider(height: 20.0, color: Color.fromARGB(33, 33, 33, 6)), | |
| ), | |
| Container( | |
| child: Row( | |
| mainAxisAlignment: MainAxisAlignment.spaceBetween, | |
| children: <Widget>[ | |
| Container( | |
| child: Text( | |
| 'Push Notifications', | |
| style: TextStyle( | |
| fontSize: 19.0, | |
| color: Colors.black, | |
| ), | |
| ), | |
| margin: EdgeInsets.only(left: 30.0), | |
| ), | |
| Switch( | |
| value: false, | |
| onChanged: (v) {}, | |
| activeTrackColor: Colors.black87, | |
| activeColor: Colors.red[900], | |
| ) | |
| ], | |
| ), | |
| ), | |
| Container( | |
| child: Row( | |
| mainAxisAlignment: MainAxisAlignment.spaceBetween, | |
| children: <Widget>[ | |
| Container( | |
| child: Text( | |
| 'Email Notifications', | |
| style: TextStyle( | |
| fontSize: 19.0, | |
| color: Colors.black, | |
| ), | |
| ), | |
| margin: EdgeInsets.only(left: 30.0), | |
| ), | |
| Switch( | |
| value: false, | |
| onChanged: (v) {}, | |
| activeTrackColor: Colors.black87, | |
| activeColor: Colors.red[900], | |
| ) | |
| ], | |
| ), | |
| ) | |
| ], | |
| ); | |
| } | |
| Widget _journalists() { | |
| return Container( | |
| padding: EdgeInsets.all(20.0), | |
| decoration: BoxDecoration( | |
| color: const Color(0xff424242), | |
| ), | |
| child: Column( | |
| crossAxisAlignment: CrossAxisAlignment.stretch, | |
| children: <Widget>[ | |
| Row( | |
| mainAxisAlignment: MainAxisAlignment.spaceBetween, | |
| children: <Widget>[ | |
| Container( | |
| margin: EdgeInsets.only(left: 6.0), | |
| child: Text( | |
| 'Journalists', | |
| textAlign: TextAlign.start, | |
| style: TextStyle(color: Colors.white, fontSize: 14.0), | |
| ), | |
| ), | |
| Container( | |
| margin: EdgeInsets.only(right: 6.0), | |
| child: Text( | |
| 'Following 200', | |
| textAlign: TextAlign.end, | |
| style: TextStyle(color: Color(0xFF9E9E9E), fontSize: 14.0), | |
| ), | |
| ), | |
| ], | |
| ) | |
| ], | |
| ), | |
| ); | |
| } | |
| Widget _termsOfService() { | |
| return Container( | |
| child: Row( | |
| mainAxisAlignment: MainAxisAlignment.center, | |
| children: <Widget>[ | |
| Container( | |
| margin: EdgeInsets.all(3.0), | |
| padding: EdgeInsets.only( | |
| left: 42.0, right: 42.0, top: 32.0, bottom: 32.0), | |
| decoration: BoxDecoration( | |
| color: const Color(0xff8A0000), | |
| borderRadius: BorderRadius.circular(10), | |
| boxShadow: [ | |
| BoxShadow( | |
| color: Colors.grey.withOpacity(0.8), | |
| spreadRadius: 5, | |
| blurRadius: 5, | |
| offset: Offset(0, 7), // changes position of shadow | |
| ), | |
| ], | |
| ), | |
| child: Center( | |
| child: Column( | |
| children: <Widget>[ | |
| SvgPicture.asset('assets/need_help.svg', | |
| height: 19.0, width: 19.0), | |
| SizedBox( | |
| height: 10.0, | |
| ), | |
| Text( | |
| 'Need', | |
| style: TextStyle(color: Colors.white, fontSize: 11.0), | |
| ), | |
| Text('Help', | |
| style: TextStyle(color: Colors.white, fontSize: 11.0)) | |
| ], | |
| ), | |
| ), | |
| ), | |
| Container( | |
| margin: EdgeInsets.all(3.0), | |
| padding: EdgeInsets.only( | |
| left: 32.0, right: 32.0, top: 32.0, bottom: 32.0), | |
| decoration: BoxDecoration( | |
| color: const Color(0xffB00222), | |
| borderRadius: BorderRadius.circular(10), | |
| boxShadow: [ | |
| BoxShadow( | |
| color: Colors.grey.withOpacity(0.8), | |
| spreadRadius: 5, | |
| blurRadius: 5, | |
| offset: Offset(0, 7), // changes position of shadow | |
| ), | |
| ], | |
| ), | |
| child: Center( | |
| child: Column( | |
| children: <Widget>[ | |
| SvgPicture.asset('assets/terms_of_service.svg', | |
| height: 19.0, width: 19.0), | |
| SizedBox( | |
| height: 10.0, | |
| ), | |
| Text( | |
| 'Terms of', | |
| style: TextStyle(color: Colors.white, fontSize: 11.0), | |
| ), | |
| Text('service', | |
| style: TextStyle(color: Colors.white, fontSize: 11.0)) | |
| ], | |
| ), | |
| ), | |
| ), | |
| Container( | |
| margin: EdgeInsets.all(3.0), | |
| padding: EdgeInsets.only( | |
| left: 42.0, right: 42.0, top: 32.0, bottom: 32.0), | |
| decoration: BoxDecoration( | |
| color: const Color(0xffD2232A), | |
| borderRadius: BorderRadius.circular(10), | |
| boxShadow: [ | |
| BoxShadow( | |
| color: Colors.grey.withOpacity(0.8), | |
| spreadRadius: 5, | |
| blurRadius: 5, | |
| offset: Offset(0, 7), // changes position of shadow | |
| ), | |
| ], | |
| ), | |
| child: Center( | |
| child: Column( | |
| children: <Widget>[ | |
| SvgPicture.asset('assets/privacy_policy.svg', | |
| height: 19.0, width: 19.0), | |
| SizedBox( | |
| height: 10.0, | |
| ), | |
| Text( | |
| 'Privacy', | |
| style: TextStyle(color: Colors.white, fontSize: 11.0), | |
| ), | |
| Text('policy', | |
| style: TextStyle(color: Colors.white, fontSize: 11.0)) | |
| ], | |
| ), | |
| ), | |
| ) | |
| ], | |
| ), | |
| ); | |
| } | |
| } | |
| class MoreCategoriesPlaceHolder extends StatefulWidget { | |
| @override | |
| _MoreCategoriesPlaceHolderState createState() => | |
| _MoreCategoriesPlaceHolderState(); | |
| } | |
| class _MoreCategoriesPlaceHolderState extends State<MoreCategoriesPlaceHolder> { | |
| List<MoreCategoryModel> _list = new List(); | |
| int moreCatColorOne = 0xFF8A0000; | |
| int moreCatColorTwo = 0xFFB00222; | |
| int moreCatColorThree = 0xFFC21828; | |
| int moreCatColorFour = 0xFFD2232A; | |
| int moreCatColorFive = 0xFFD2232A; | |
| Color moreCatColorText = const Color(0xFF9E9E9E); | |
| @override | |
| Widget build(BuildContext context) { | |
| _list.add(MoreCategoryModel(Icons.business, "Bussiness", moreCatColorOne)); | |
| _list.add( | |
| MoreCategoryModel(Icons.insert_chart, "Statistics", moreCatColorTwo)); | |
| _list.add(MoreCategoryModel(Icons.school, "Education", moreCatColorThree)); | |
| _list.add(MoreCategoryModel( | |
| Icons.directions_transit, "Transport", moreCatColorFour)); | |
| _list.add(MoreCategoryModel( | |
| Icons.supervisor_account, "Social", moreCatColorFive)); | |
| return Column( | |
| children: <Widget>[ | |
| Row( | |
| mainAxisAlignment: MainAxisAlignment.spaceBetween, | |
| children: <Widget>[ | |
| Container( | |
| margin: EdgeInsets.only(left: 30.0, top: 40.0), | |
| child: Text( | |
| 'Interests', | |
| textAlign: TextAlign.start, | |
| style: TextStyle( | |
| color: Color(0xFFDE000000), | |
| fontSize: 16.0, | |
| fontWeight: FontWeight.bold), | |
| ), | |
| ), | |
| Container( | |
| margin: EdgeInsets.only(right: 29.0, top: 40.0), | |
| child: Text( | |
| 'EDIT INTERESTS', | |
| textAlign: TextAlign.end, | |
| style: TextStyle( | |
| color: Color(0xFF757575), | |
| fontWeight: FontWeight.bold, | |
| fontSize: 14.0), | |
| ), | |
| ) | |
| ], | |
| ), | |
| Container( | |
| height: 150.0, | |
| child: Container( | |
| margin: EdgeInsets.only(left: 30.0), | |
| child: buildMoreCategoryList(_list))) | |
| ], | |
| ); | |
| } | |
| Widget buildMoreCategoryList(List<MoreCategoryModel> more_categories) { | |
| return ListView.builder( | |
| scrollDirection: Axis.horizontal, | |
| itemCount: 5, | |
| itemBuilder: (ctx, position) { | |
| return Row( | |
| children: <Widget>[ | |
| Column( | |
| children: <Widget>[ | |
| Card( | |
| clipBehavior: Clip.antiAliasWithSaveLayer, | |
| elevation: 2, | |
| color: Color(more_categories[position].color), | |
| margin: EdgeInsets.all(10), | |
| child: Padding( | |
| padding: const EdgeInsets.all(23.0), | |
| child: Icon( | |
| more_categories[position].iconCategory, | |
| color: Colors.white, | |
| ), | |
| )), | |
| Text( | |
| more_categories[position].nameCategory, | |
| style: TextStyle(color: moreCatColorText), | |
| ) | |
| ], | |
| ), | |
| ], | |
| ); | |
| }); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment