Hibok
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 
 

237 wiersze
6.6 KiB

  1. import 'package:chat/data/UserData.dart';
  2. import 'package:chat/data/constants.dart';
  3. import 'package:chat/generated/i18n.dart';
  4. import 'package:chat/home/DiscoverPage.dart';
  5. import 'package:chat/home/ParkPage.dart';
  6. import 'package:chat/home/follow_user_dynamic.dart';
  7. import 'package:chat/utils/CustomUI.dart';
  8. import 'package:flutter/material.dart';
  9. import 'package:location_permissions/location_permissions.dart';
  10. import 'package:oktoast/oktoast.dart';
  11. class FindPage extends StatefulWidget {
  12. FindPage({Key key}) : super(key: key);
  13. @override
  14. _FindPageState createState() => new _FindPageState();
  15. }
  16. class _FindPageState extends State<FindPage> {
  17. @override
  18. void initState() {
  19. super.initState();
  20. }
  21. @override
  22. Widget build(BuildContext context) {
  23. Widget appBar = new AppBar(
  24. backgroundColor: AppColors.NewAppbarBgColor,
  25. title: new Text(I18n.of(context).find,
  26. textScaleFactor: 1.0, style: Constants.MainTitleStyle),
  27. centerTitle: false,
  28. elevation: 1,
  29. );
  30. return SafeArea(
  31. child: Scaffold(
  32. appBar: appBar,
  33. body: _buildBody(),
  34. ));
  35. }
  36. _buildBody() {
  37. return Column(
  38. children: <Widget>[
  39. _buildRadioButton(),
  40. _buildMyProgramButton(),
  41. _buildNearButton(),
  42. _buildScanButton(),
  43. ],
  44. );
  45. }
  46. _buildIconButton(Widget icon, Gradient gradient, String text, callback,
  47. {double marginTop: 12, bool showDivder: false}) {
  48. return InkWell(
  49. onTap: callback,
  50. child: Container(
  51. margin: EdgeInsets.only(top: marginTop),
  52. padding: EdgeInsets.only(left: 16.5, right: 20, top: 9, bottom: 9),
  53. decoration: BoxDecoration(
  54. color: Colors.white,
  55. border:
  56. showDivder ? Border(top: Constants.GreyBorderSide) : null),
  57. child: Row(
  58. children: <Widget>[
  59. Stack(
  60. alignment: Alignment.center,
  61. children: <Widget>[
  62. Container(
  63. width: Constants.ContactAvatarSize,
  64. height: Constants.ContactAvatarSize,
  65. decoration: BoxDecoration(
  66. gradient: gradient,
  67. borderRadius: BorderRadius.circular(4)),
  68. ),
  69. icon
  70. ],
  71. ),
  72. Expanded(
  73. child: Container(
  74. margin: EdgeInsets.only(left: 15),
  75. child: Text(
  76. text,
  77. style: TextStyle(fontSize: 16),
  78. ),
  79. ),
  80. ),
  81. Icon(
  82. IconData(0xe63c, fontFamily: 'iconfont'),
  83. size: 25.0,
  84. color: Color(AppColors.TabIconNormal),
  85. )
  86. ],
  87. )));
  88. }
  89. _buildRadioButton() {
  90. Widget icon = Positioned(
  91. // left: 4.5,
  92. top: 5,
  93. child: Icon(
  94. IconData(0xe66b, fontFamily: Constants.IconFontFamily),
  95. color: Colors.white,
  96. ));
  97. var gradient = LinearGradient(
  98. begin: Alignment.topCenter,
  99. end: Alignment.bottomCenter,
  100. colors: <Color>[
  101. const Color(0xFFFBD25C),
  102. const Color(0xFFF57723),
  103. ]);
  104. return _buildIconButton(icon, gradient, I18n.of(context).radio, () {
  105. if (!UserData().stationOpenSwitch) {
  106. showToast(I18n.of(context).system_not_open);
  107. return;
  108. }
  109. if (!UserData().hasLocationPermission) {
  110. CustomUI.buildOneConfirm(
  111. context, I18n.of(context).get_location, I18n.of(context).determine,
  112. () {
  113. Navigator.of(context).pop();
  114. LocationPermissions().openAppSettings();
  115. });
  116. return;
  117. }
  118. Navigator.of(context).push(
  119. new MaterialPageRoute(
  120. builder: (context) {
  121. return ParkPage();
  122. },
  123. ),
  124. );
  125. });
  126. }
  127. _buildMyProgramButton() {
  128. Widget icon = Icon(
  129. IconData(0xe66d, fontFamily: Constants.IconFontFamily),
  130. color: Colors.white,
  131. );
  132. var gradient = LinearGradient(
  133. begin: Alignment.topCenter,
  134. end: Alignment.bottomCenter,
  135. colors: <Color>[
  136. const Color(0xFFF87354),
  137. const Color(0xFFF23D6B),
  138. ]);
  139. return _buildIconButton(
  140. icon,
  141. gradient,
  142. UserData().isMan()
  143. ? I18n.of(context).woman_gold
  144. : I18n.of(context).man_gold, () {
  145. if (!UserData().myProgramOpenSwitch) {
  146. showToast(I18n.of(context).system_not_open);
  147. return;
  148. }
  149. Navigator.of(context).push(
  150. new MaterialPageRoute(
  151. builder: (context) {
  152. return FollowUserPage();
  153. },
  154. ),
  155. );
  156. }, marginTop: 0, showDivder: true);
  157. }
  158. _buildNearButton() {
  159. Widget icon = Icon(
  160. IconData(0xe665, fontFamily: Constants.IconFontFamily),
  161. color: Colors.white,
  162. );
  163. var gradient = LinearGradient(
  164. begin: Alignment.topCenter,
  165. end: Alignment.bottomCenter,
  166. colors: <Color>[
  167. const Color(0xFFB678FF),
  168. const Color(0xFF6760FC),
  169. ]);
  170. return _buildIconButton(icon, gradient, I18n.of(context).nearby, () {
  171. if (!UserData().nearbyOpenSwitch) {
  172. showToast(I18n.of(context).system_not_open);
  173. return;
  174. }
  175. if (!UserData().hasLocationPermission) {
  176. CustomUI.buildOneConfirm(
  177. context, I18n.of(context).get_location, I18n.of(context).determine,
  178. () {
  179. Navigator.of(context).pop();
  180. LocationPermissions().openAppSettings();
  181. });
  182. return;
  183. }
  184. Navigator.of(context).push(
  185. new MaterialPageRoute(
  186. builder: (context) {
  187. return DisCoverPage();
  188. },
  189. ),
  190. );
  191. });
  192. }
  193. _buildScanButton() {
  194. Widget icon = Positioned(
  195. top: 5,
  196. child: Icon(
  197. IconData(0xe666, fontFamily: Constants.IconFontFamily),
  198. color: Colors.white,
  199. ));
  200. var gradient = LinearGradient(
  201. begin: Alignment.topCenter,
  202. end: Alignment.bottomCenter,
  203. colors: <Color>[
  204. const Color(0xFF48DFF2),
  205. const Color(0xFF0080FF),
  206. ]);
  207. return _buildIconButton(icon, gradient, I18n.of(context).scan, () {
  208. CustomUI().goScanPage(context);
  209. });
  210. }
  211. @override
  212. void dispose() {
  213. super.dispose();
  214. }
  215. }