demo_page.dart 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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.multiImageColorFit("assets/images/splash_center_blue_logo.webp", 144, 112, darkColor: Colors.white),
  106. const SizedBox(height: 10.0),
  107. MyInputField(
  108. controller: controller.registerEmailController,
  109. keyboardType: TextInputType.text,
  110. labelText: '',
  111. placeholder: 'Enter Email Address',
  112. validator: (value) {
  113. if (value?.isEmpty ?? true) {
  114. return 'Email is required.';
  115. }
  116. return null;
  117. },
  118. ),
  119. const SizedBox(height: 10.0),
  120. MyClickItem(
  121. title: '测试SP-存和取',
  122. drawablePadding: 0,
  123. onTap: () {
  124. SpUtil.putString("username", "Sky24n");
  125. SpUtil.putString(SPConstant.SP_KEY_TOKEN,
  126. "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC95eWpvYnMtYXBpLWRldi5ndWFiZWFuLmNvbVwvaW5kZXgucGhwXC9hcGlcL2VtcGxveWVlXC9hdXRoXC9sb2dpbiIsImlhdCI6MTY1MDQyMDQxMiwiZXhwIjoxNjg2NDIwNDEyLCJuYmYiOjE2NTA0MjA0MTIsImp0aSI6IjlWNmgyS29qQ1BJZ1NSa2MiLCJzdWIiOjI4OTQ3LCJwcnYiOiI4NjY1YWU5Nzc1Y2YyNmY2YjhlNDk2Zjg2ZmE1MzZkNjhkZDcxODE4In0.X2kXCz2HcBvVxBVTB-JQTou56pCh_t221WTZdVHpM5M");
  127. String? userName = SpUtil.getString("username");
  128. if (!TextUtil.isEmpty(userName)) {
  129. SmartDialog.compatible.showToast('username:$userName');
  130. }
  131. },
  132. backgroundColor: ColorConstants.dividerColor,
  133. ),
  134. const SizedBox(height: 10.0),
  135. TextButton(
  136. child: const Text(
  137. '测试吐司与Log',
  138. style: TextStyle(fontSize: 16, color: Colors.white),
  139. ),
  140. onPressed: () {
  141. SmartDialog.compatible.showToast('test toast');
  142. Log.d("我是Lop数据 -ddd");
  143. Log.e("我是Lop数据 -eee");
  144. SmartDialog.compatible.showLoading();
  145. },
  146. style: ButtonStyle(
  147. backgroundColor: MaterialStateProperty.all<Color>(Colors.redAccent), // 设置背景颜色为蓝色
  148. ),
  149. // color: Colors.redAccent,
  150. // textColor: Colors.white,
  151. // disabledColor: Colors.black,
  152. // disabledTextColor: Colors.black38,
  153. // splashColor: Colors.white, //水波纹的颜色
  154. ),
  155. const SizedBox(height: 10.0),
  156. ElevatedButton(
  157. // color: Colors.blue,
  158. // highlightColor: Colors.blue[700],
  159. // colorBrightness: Brightness.dark,
  160. // splashColor: Colors.grey,
  161. child: const Text("测试弹窗"),
  162. // shape: RoundedRectangleBorder(
  163. // borderRadius: BorderRadius.circular(20.0)),
  164. onPressed: () async {
  165. SmartDialog.compatible.showLoading(clickBgDismissTemp: true);
  166. SmartDialog.compatible.dismiss();
  167. },
  168. style: ButtonStyle(
  169. backgroundColor: MaterialStateProperty.all<Color>(Colors.blue), // 设置背景色为蓝色
  170. elevation: MaterialStateProperty.all<double>(10), // 设置阴影的程度
  171. textStyle: MaterialStateProperty.all<TextStyle>(TextStyle(fontSize: 20)), // 设置文本的样式
  172. padding:
  173. MaterialStateProperty.all<EdgeInsets>(EdgeInsets.symmetric(horizontal: 16, vertical: 8)), // 设置内边距
  174. ),
  175. ),
  176. const SizedBox(height: 10.0),
  177. MyButton(
  178. text: "切换主题-黑暗模式",
  179. backgroundColor: Colors.lightBlue,
  180. radius: 5,
  181. onPressed: () {
  182. SmartDialog.compatible.showToast("切换主题");
  183. Get.to(() => const ThemePage());
  184. },
  185. ),
  186. const SizedBox(height: 10.0),
  187. MyTextView("自定义textview自定义textview自定义textview自定义textview自定义textview",
  188. backgroundColor: Colors.red,
  189. textColor: Colors.white,
  190. padding: 10,
  191. cornerRadius: 10,
  192. borderColor: Colors.yellow,
  193. borderWidth: 1,
  194. marginTop: 5,
  195. singleLine: false, onClick: () {
  196. Log.d("点击事件");
  197. }),
  198. const SizedBox(height: 10.0),
  199. MyButton(
  200. text: "自定义圆角按钮",
  201. backgroundColor: DarkThemeUtil.multiColors(ColorConstants.dividerColor, darkColor: Colors.deepOrange),
  202. radius: 20,
  203. onPressed: () {},
  204. ),
  205. const SizedBox(height: 10.0),
  206. MyTextView("简单的TextView显示", textColor: Colors.black, singleLine: false),
  207. const SizedBox(height: 10.0),
  208. MyTextView(
  209. "Test Font Family Font Size",
  210. fontSize: 18,
  211. textColor: Colors.black,
  212. singleLine: false,
  213. isFonTimeNew: true,
  214. ),
  215. const SizedBox(height: 10.0),
  216. MyLoadImage(
  217. 'https://i04piccdn.sogoucdn.com/a35bde4b5756167a',
  218. width: 340,
  219. height: 191,
  220. cornerRadius: 15,
  221. borderColor: Colors.red,
  222. borderWidth: 1,
  223. ),
  224. const SizedBox(height: 10.0),
  225. Row(
  226. //如果不包裹容器,默认宽度会充满全屏的
  227. children: [
  228. MyLoadImage(
  229. 'https://i04piccdn.sogoucdn.com/a35bde4b5756167a',
  230. width: 100,
  231. height: 100,
  232. isCircle: true,
  233. onClick: () {
  234. SmartDialog.compatible.show(
  235. widget: Container(
  236. height: 80,
  237. width: 180,
  238. decoration: BoxDecoration(
  239. color: Colors.black,
  240. borderRadius: BorderRadius.circular(10),
  241. ),
  242. alignment: Alignment.center,
  243. child: Text(
  244. 'easy custom dialog',
  245. style: TextStyle(color: Colors.white),
  246. ),
  247. ));
  248. },
  249. ),
  250. ],
  251. ),
  252. const SizedBox(height: 10),
  253. ElevatedButton(
  254. child: const Text("Test Future"),
  255. onPressed: () {
  256. controller.testFuture();
  257. }),
  258. ],
  259. ),
  260. ),
  261. );
  262. }
  263. }