Hibok
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

238 lines
6.7 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. textScaleFactor: 1.0,
  78. style: TextStyle(fontSize: 16),
  79. ),
  80. ),
  81. ),
  82. Icon(
  83. IconData(0xe63c, fontFamily: 'iconfont'),
  84. size: 25.0,
  85. color: Color(AppColors.TabIconNormal),
  86. )
  87. ],
  88. )));
  89. }
  90. _buildRadioButton() {
  91. Widget icon = Positioned(
  92. // left: 4.5,
  93. top: 5,
  94. child: Icon(
  95. IconData(0xe66b, fontFamily: Constants.IconFontFamily),
  96. color: Colors.white,
  97. ));
  98. var gradient = LinearGradient(
  99. begin: Alignment.topCenter,
  100. end: Alignment.bottomCenter,
  101. colors: <Color>[
  102. const Color(0xFFFBD25C),
  103. const Color(0xFFF57723),
  104. ]);
  105. return _buildIconButton(icon, gradient, I18n.of(context).radio, () {
  106. if (!UserData().stationOpenSwitch) {
  107. showToast(I18n.of(context).system_not_open);
  108. return;
  109. }
  110. if (!UserData().hasLocationPermission) {
  111. CustomUI.buildOneConfirm(
  112. context, I18n.of(context).get_location, I18n.of(context).determine,
  113. () {
  114. Navigator.of(context).pop();
  115. LocationPermissions().openAppSettings();
  116. });
  117. return;
  118. }
  119. Navigator.of(context).push(
  120. new MaterialPageRoute(
  121. builder: (context) {
  122. return ParkPage();
  123. },
  124. ),
  125. );
  126. });
  127. }
  128. _buildMyProgramButton() {
  129. Widget icon = Icon(
  130. IconData(0xe66d, fontFamily: Constants.IconFontFamily),
  131. color: Colors.white,
  132. );
  133. var gradient = LinearGradient(
  134. begin: Alignment.topCenter,
  135. end: Alignment.bottomCenter,
  136. colors: <Color>[
  137. const Color(0xFFF87354),
  138. const Color(0xFFF23D6B),
  139. ]);
  140. return _buildIconButton(
  141. icon,
  142. gradient,
  143. UserData().isMan()
  144. ? I18n.of(context).woman_gold
  145. : I18n.of(context).man_gold, () {
  146. if (!UserData().myProgramOpenSwitch) {
  147. showToast(I18n.of(context).system_not_open);
  148. return;
  149. }
  150. Navigator.of(context).push(
  151. new MaterialPageRoute(
  152. builder: (context) {
  153. return FollowUserPage();
  154. },
  155. ),
  156. );
  157. }, marginTop: 0, showDivder: true);
  158. }
  159. _buildNearButton() {
  160. Widget icon = Icon(
  161. IconData(0xe665, fontFamily: Constants.IconFontFamily),
  162. color: Colors.white,
  163. );
  164. var gradient = LinearGradient(
  165. begin: Alignment.topCenter,
  166. end: Alignment.bottomCenter,
  167. colors: <Color>[
  168. const Color(0xFFB678FF),
  169. const Color(0xFF6760FC),
  170. ]);
  171. return _buildIconButton(icon, gradient, I18n.of(context).nearby, () {
  172. if (!UserData().nearbyOpenSwitch) {
  173. showToast(I18n.of(context).system_not_open);
  174. return;
  175. }
  176. if (!UserData().hasLocationPermission) {
  177. CustomUI.buildOneConfirm(
  178. context, I18n.of(context).get_location, I18n.of(context).determine,
  179. () {
  180. Navigator.of(context).pop();
  181. LocationPermissions().openAppSettings();
  182. });
  183. return;
  184. }
  185. Navigator.of(context).push(
  186. new MaterialPageRoute(
  187. builder: (context) {
  188. return DisCoverPage();
  189. },
  190. ),
  191. );
  192. });
  193. }
  194. _buildScanButton() {
  195. Widget icon = Positioned(
  196. top: 5,
  197. child: Icon(
  198. IconData(0xe666, fontFamily: Constants.IconFontFamily),
  199. color: Colors.white,
  200. ));
  201. var gradient = LinearGradient(
  202. begin: Alignment.topCenter,
  203. end: Alignment.bottomCenter,
  204. colors: <Color>[
  205. const Color(0xFF48DFF2),
  206. const Color(0xFF0080FF),
  207. ]);
  208. return _buildIconButton(icon, gradient, I18n.of(context).scan, () {
  209. CustomUI().goScanPage(context);
  210. });
  211. }
  212. @override
  213. void dispose() {
  214. super.dispose();
  215. }
  216. }