demo_page.dart 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. import 'package:flustars/flustars.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter/services.dart';
  4. import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
  5. import 'package:get/get.dart';
  6. import 'package:ftrecruiter/comm/constants/color_constants.dart';
  7. import 'package:ftrecruiter/comm/constants/sp_constant.dart';
  8. import 'package:ftrecruiter/comm/utils/log_utils.dart';
  9. import 'package:ftrecruiter/comm/widget/my_click_item.dart';
  10. import 'package:ftrecruiter/comm/widget/my_input_field.dart';
  11. import 'package:ftrecruiter/comm/widget/my_button.dart';
  12. import 'package:ftrecruiter/comm/widget/common_widget.dart';
  13. import 'package:ftrecruiter/comm/utils/dark_theme_util.dart';
  14. import 'package:ftrecruiter/comm/widget/my_load_image.dart';
  15. import 'package:ftrecruiter/comm/widget/my_text_view.dart';
  16. import 'package:ftrecruiter/modules/zdemo/demo_load_page.dart';
  17. import 'package:ftrecruiter/modules/zdemo/demo_scroll1.dart';
  18. import 'package:ftrecruiter/modules/zdemo/theme_page.dart';
  19. import 'demo_controller.dart';
  20. class DemoPage extends GetView<DemoController> {
  21. @override
  22. Widget build(BuildContext context) {
  23. return Scaffold(
  24. backgroundColor: DarkThemeUtil.multiColors(Colors.white),
  25. appBar: CommonWidget.appBar(context, "Demo"),
  26. body: Container(
  27. width: double.infinity,
  28. height: double.infinity,
  29. child: ListView(
  30. shrinkWrap: true,
  31. padding: const EdgeInsets.symmetric(horizontal: 30.0),
  32. children: [
  33. const SizedBox(height: 20.0),
  34. Row(
  35. children: [
  36. Text(
  37. 'welcome'.tr,
  38. textAlign: TextAlign.left,
  39. softWrap: true,
  40. style: const TextStyle(fontSize: 20, color: Colors.black, decoration: TextDecoration.none),
  41. ),
  42. ],
  43. ),
  44. const SizedBox(height: 10.0),
  45. Text(
  46. 'title'.tr,
  47. textAlign: TextAlign.center,
  48. style: TextStyle(
  49. fontSize: 22,
  50. decoration: TextDecoration.none,
  51. color: Theme.of(context).textTheme.subtitle1!.color,
  52. ),
  53. ),
  54. const SizedBox(height: 10.0),
  55. Row(
  56. //宽度不想充满屏幕,可以使用row包裹
  57. children: [
  58. ElevatedButton(
  59. child: const Text("Go To Demo Load Page"),
  60. onPressed: () {
  61. Get.to(() => DemoLoadPage());
  62. }),
  63. const SizedBox(width: 15.0),
  64. ElevatedButton(
  65. child: const Text("Go To Scroll Page"),
  66. onPressed: () {
  67. Get.to(() => DemoScroll1Page());
  68. })
  69. ],
  70. ),
  71. CommonWidget.rowHeight(height: 10),
  72. TextButton(
  73. style: ButtonStyle(
  74. minimumSize: MaterialStateProperty.all<Size>(Size(200, 45)), // 设置最小宽度和高度
  75. backgroundColor: MaterialStateProperty.all<Color>(Colors.redAccent),
  76. ),
  77. onPressed: () {
  78. //调用接口
  79. controller.getServerTime();
  80. },
  81. child: const Text(
  82. '网络请求获取数据',
  83. style: TextStyle(fontSize: 16, color: Colors.white),
  84. ),
  85. // color: Colors.redAccent,
  86. // textColor: Colors.white,
  87. // disabledColor: Colors.black,
  88. // disabledTextColor: Colors.black38,
  89. // splashColor: Colors.white, //水波纹的颜色
  90. ),
  91. const SizedBox(height: 10.0),
  92. controller.obx(
  93. (state) => Text(
  94. "time:${state?.timestamps}",
  95. textAlign: TextAlign.center,
  96. style: TextStyle(
  97. fontSize: 22,
  98. color: Theme.of(context).textTheme.subtitle1!.color,
  99. ),
  100. ),
  101. onError: (err) => Text("onEmpty" + err.toString()),
  102. onEmpty: const Text("onEmpty"),
  103. ),
  104. const SizedBox(height: 10.0),
  105. DarkThemeUtil.multiImageColor("assets/images/splash_center_blue_logo.webp", 144, 112,
  106. darkColor: Colors.white),
  107. const SizedBox(height: 10.0),
  108. MyInputField(
  109. controller: controller.registerEmailController,
  110. keyboardType: TextInputType.text,
  111. labelText: '',
  112. placeholder: 'Enter Email Address',
  113. validator: (value) {
  114. if (value?.isEmpty ?? true) {
  115. return 'Email is required.';
  116. }
  117. return null;
  118. },
  119. ),
  120. const SizedBox(height: 10.0),
  121. MyClickItem(
  122. title: '测试SP-存和取',
  123. drawablePadding: 0,
  124. onTap: () {
  125. SpUtil.putString("username", "Sky24n");
  126. SpUtil.putString(SPConstant.SP_KEY_TOKEN,
  127. "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC95eWpvYnMtYXBpLWRldi5ndWFiZWFuLmNvbVwvaW5kZXgucGhwXC9hcGlcL2VtcGxveWVlXC9hdXRoXC9sb2dpbiIsImlhdCI6MTY1MDQyMDQxMiwiZXhwIjoxNjg2NDIwNDEyLCJuYmYiOjE2NTA0MjA0MTIsImp0aSI6IjlWNmgyS29qQ1BJZ1NSa2MiLCJzdWIiOjI4OTQ3LCJwcnYiOiI4NjY1YWU5Nzc1Y2YyNmY2YjhlNDk2Zjg2ZmE1MzZkNjhkZDcxODE4In0.X2kXCz2HcBvVxBVTB-JQTou56pCh_t221WTZdVHpM5M");
  128. String? userName = SpUtil.getString("username");
  129. if (!TextUtil.isEmpty(userName)) {
  130. SmartDialog.compatible.showToast('username:$userName');
  131. }
  132. },
  133. backgroundColor: ColorConstants.dividerColor,
  134. ),
  135. const SizedBox(height: 10.0),
  136. TextButton(
  137. child: const Text(
  138. '测试吐司与Log',
  139. style: TextStyle(fontSize: 16, color: Colors.white),
  140. ),
  141. onPressed: () {
  142. SmartDialog.compatible.showToast('test toast');
  143. Log.d("我是Lop数据 -ddd");
  144. Log.e("我是Lop数据 -eee");
  145. SmartDialog.compatible.showLoading();
  146. },
  147. style: ButtonStyle(
  148. backgroundColor: MaterialStateProperty.all<Color>(Colors.redAccent), // 设置背景颜色为蓝色
  149. ),
  150. // color: Colors.redAccent,
  151. // textColor: Colors.white,
  152. // disabledColor: Colors.black,
  153. // disabledTextColor: Colors.black38,
  154. // splashColor: Colors.white, //水波纹的颜色
  155. ),
  156. const SizedBox(height: 10.0),
  157. ElevatedButton(
  158. // color: Colors.blue,
  159. // highlightColor: Colors.blue[700],
  160. // colorBrightness: Brightness.dark,
  161. // splashColor: Colors.grey,
  162. child: const Text("测试弹窗"),
  163. // shape: RoundedRectangleBorder(
  164. // borderRadius: BorderRadius.circular(20.0)),
  165. onPressed: () async {
  166. SmartDialog.compatible.showLoading(clickBgDismissTemp: true);
  167. SmartDialog.compatible.dismiss();
  168. },
  169. style: ButtonStyle(
  170. backgroundColor: MaterialStateProperty.all<Color>(Colors.blue), // 设置背景色为蓝色
  171. elevation: MaterialStateProperty.all<double>(10), // 设置阴影的程度
  172. textStyle: MaterialStateProperty.all<TextStyle>(TextStyle(fontSize: 20)), // 设置文本的样式
  173. padding:
  174. MaterialStateProperty.all<EdgeInsets>(EdgeInsets.symmetric(horizontal: 16, vertical: 8)), // 设置内边距
  175. ),
  176. ),
  177. const SizedBox(height: 10.0),
  178. MyButton(
  179. text: "切换主题-黑暗模式",
  180. backgroundColor: Colors.lightBlue,
  181. radius: 5,
  182. onPressed: () {
  183. SmartDialog.compatible.showToast("切换主题");
  184. Get.to(() => const ThemePage());
  185. },
  186. ),
  187. const SizedBox(height: 10.0),
  188. MyTextView("自定义textview自定义textview自定义textview自定义textview自定义textview",
  189. backgroundColor: Colors.red,
  190. textColor: Colors.white,
  191. padding: 10,
  192. cornerRadius: 10,
  193. borderColor: Colors.yellow,
  194. borderWidth: 1,
  195. marginTop: 5,
  196. singleLine: false, onClick: () {
  197. Log.d("点击事件");
  198. }),
  199. const SizedBox(height: 10.0),
  200. MyButton(
  201. text: "自定义圆角按钮",
  202. backgroundColor: DarkThemeUtil.multiColors(ColorConstants.dividerColor, darkColor: Colors.deepOrange),
  203. radius: 20,
  204. onPressed: () {},
  205. ),
  206. const SizedBox(height: 10.0),
  207. MyTextView("简单的TextView显示", textColor: Colors.black, singleLine: false),
  208. const SizedBox(height: 10.0),
  209. MyTextView(
  210. "Test Font Family Font Size",
  211. fontSize: 18,
  212. textColor: Colors.black,
  213. singleLine: false,
  214. isFonTimeNew: true,
  215. ),
  216. const SizedBox(height: 10.0),
  217. MyLoadImage(
  218. 'https://i04piccdn.sogoucdn.com/a35bde4b5756167a',
  219. width: 340,
  220. height: 191,
  221. cornerRadius: 15,
  222. borderColor: Colors.red,
  223. borderWidth: 1,
  224. ),
  225. const SizedBox(height: 10.0),
  226. Row(
  227. //如果不包裹容器,默认宽度会充满全屏的
  228. children: [
  229. MyLoadImage(
  230. 'https://i04piccdn.sogoucdn.com/a35bde4b5756167a',
  231. width: 100,
  232. height: 100,
  233. isCircle: true,
  234. onClick: () {
  235. SmartDialog.compatible.show(
  236. widget: Container(
  237. height: 80,
  238. width: 180,
  239. decoration: BoxDecoration(
  240. color: Colors.black,
  241. borderRadius: BorderRadius.circular(10),
  242. ),
  243. alignment: Alignment.center,
  244. child: Text(
  245. 'easy custom dialog',
  246. style: TextStyle(color: Colors.white),
  247. ),
  248. ));
  249. },
  250. ),
  251. ],
  252. ),
  253. const SizedBox(height: 10),
  254. ElevatedButton(
  255. child: const Text("Test Future"),
  256. onPressed: () {
  257. controller.testFuture();
  258. }),
  259. ],
  260. ),
  261. ),
  262. );
  263. }
  264. }