Advertisement
Guest User

Untitled

a guest
Jun 14th, 2020
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.07 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/cupertino.dart';
  3. import 'package:flutter/services.dart';
  4. import 'package:flutter_svg/svg.dart';
  5.  
  6. import 'package:easy_localization/easy_localization.dart';
  7.  
  8. import 'package:carma/utils/styles.dart';
  9.  
  10. class UserPage extends StatefulWidget {
  11. @override
  12. _SliverWithTabBarState createState() => _SliverWithTabBarState();
  13. }
  14.  
  15. class _SliverWithTabBarState extends State<UserPage> with SingleTickerProviderStateMixin {
  16. TabController controller;
  17.  
  18. @override
  19. void initState() {
  20. super.initState();
  21. controller = TabController(length: 2, vsync: this);
  22. }
  23.  
  24. @override
  25. Widget build(BuildContext context) {
  26. return Scaffold(
  27. appBar: AppBar(
  28. brightness: Brightness.dark,
  29. title: Text('user.title'.tr(), style: Styles.primaryTitleStyle),
  30. centerTitle: false,
  31. elevation: 0,
  32. actions: <Widget>[
  33. IconButton(
  34. icon: SvgPicture.asset('assets/images/icons/icon_cog.svg'),
  35. onPressed: () {
  36.  
  37. },
  38. ),
  39. ],
  40. ),
  41. body: NestedScrollView(
  42. headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
  43. return [
  44. SliverOverlapAbsorber(
  45. handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
  46. sliver: SliverAppBar(
  47. actions: <Widget>[
  48. IconButton(
  49. icon: SvgPicture.asset('assets/images/icons/icon_cog.svg'),
  50. onPressed: () {
  51.  
  52. },
  53. ),
  54. ],
  55. pinned: true,
  56. backgroundColor: Styles.whiteColor,
  57. expandedHeight: 286.0,
  58. flexibleSpace: FlexibleSpaceBar(
  59. titlePadding: EdgeInsets.zero,
  60. collapseMode: CollapseMode.pin,
  61. background: buildInfo()
  62. ),
  63. forceElevated: innerBoxIsScrolled,
  64. bottom: TabBar(
  65. controller: controller,
  66. labelColor: Styles.segmentedSelectedColor,
  67. unselectedLabelColor: Styles.segmentedNormalColor,
  68. indicatorColor: Styles.primaryColor,
  69. indicatorWeight: 2.0,
  70. labelStyle: TextStyle(
  71. fontFamily: 'NotoSans',
  72. fontSize: 14.0,
  73. fontWeight: FontWeight.w500
  74. ),
  75. tabs: [
  76. Tab(text: 'car.rating.dislikes'.tr().toUpperCase()),
  77. Tab(text: 'car.rating.likes'.tr().toUpperCase()),
  78. ],
  79. ),
  80. ),
  81. ),
  82. ];
  83. },
  84. body: TabBarView(
  85. controller: controller,
  86. children: [
  87. SafeArea(
  88. top: false,
  89. bottom: false,
  90. child: Builder(
  91. builder: (BuildContext context) {
  92. return CustomScrollView(
  93. key: PageStorageKey<String>('test'),
  94. slivers: <Widget>[
  95. SliverOverlapInjector(
  96. handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
  97. ),
  98. SliverPadding(
  99. padding: const EdgeInsets.all(8.0),
  100. sliver: SliverFixedExtentList(
  101. itemExtent: 48.0,
  102. delegate: SliverChildBuilderDelegate(
  103. (BuildContext context, int index) {
  104. return ListTile(
  105. title: Text('Item $index'),
  106. );
  107. },
  108. childCount: 30,
  109. ),
  110. ),
  111. ),
  112. ],
  113. );
  114. },
  115. ),
  116. ),
  117. SafeArea(
  118. top: false,
  119. bottom: false,
  120. child: Builder(
  121. builder: (BuildContext context) {
  122. return CustomScrollView(
  123. key: PageStorageKey<String>('test'),
  124. slivers: <Widget>[
  125. SliverOverlapInjector(
  126. handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
  127. ),
  128. SliverPadding(
  129. padding: const EdgeInsets.all(0),
  130. sliver: SliverFixedExtentList(
  131. itemExtent: 48.0,
  132. delegate: SliverChildBuilderDelegate(
  133. (BuildContext context, int index) {
  134. return ListTile(
  135. title: Text('Item $index'),
  136. );
  137. },
  138. childCount: 30,
  139. ),
  140. ),
  141. ),
  142. ],
  143. );
  144. },
  145. ),
  146. ),
  147. ],
  148. ),
  149. ),
  150. );
  151. }
  152.  
  153. Widget buildInfo() {
  154. return Container(
  155. margin: EdgeInsets.fromLTRB(0, 0, 0, 0),
  156. color: Styles.whiteColor,
  157. width: double.infinity,
  158. height: 234,
  159. child: Column(
  160. mainAxisSize: MainAxisSize.max,
  161. mainAxisAlignment: MainAxisAlignment.center,
  162. children: [
  163. SizedBox(
  164. width: 150,
  165. height: 150,
  166. child: Stack(
  167. children: [
  168. ClipRRect(
  169. borderRadius: BorderRadius.circular(75),
  170. child: Image.asset('assets/images/other/userpic.jpg', width: 150, height: 150),
  171. ),
  172. Positioned(
  173. bottom: 0,
  174. right: 0,
  175. child: Container(
  176. width: 44,
  177. height: 44,
  178. padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
  179. decoration: BoxDecoration(
  180. color: Styles.grayColor,
  181. borderRadius: BorderRadius.circular(22),
  182. ),
  183. child: SvgPicture.asset(
  184. 'assets/images/icons/icon_social_facebook.svg',
  185. color: Styles.blueColor,
  186. )
  187. ),
  188. )
  189. ],
  190. ),
  191. ),
  192. SizedBox(height: 16),
  193. Text(
  194. 'Константин Константинопольский',
  195. textAlign: TextAlign.center,
  196. style: TextStyle(
  197. fontFamily: 'NotoSans',
  198. fontSize: 16.0,
  199. fontWeight: FontWeight.w500,
  200. color: Styles.darkColor
  201. ),
  202. ),
  203. SizedBox(height: 12),
  204. ]
  205. )
  206. );
  207. }
  208. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement