基础库
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.

empty_page.dart 4.5 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. import 'package:flutter/material.dart';
  2. import 'package:zhiying_comm/pages/empty_page/bloc/empty_page_bloc.dart';
  3. import 'package:zhiying_comm/pages/empty_page/model/empty_page_model.dart';
  4. import 'package:zhiying_comm/util/update/app_update_util.dart';
  5. import 'package:zhiying_comm/zhiying_comm.dart';
  6. import 'package:flutter_bloc/flutter_bloc.dart';
  7. import 'bloc/empty_page_bloc.dart';
  8. import 'bloc/empty_page_event.dart';
  9. import 'bloc/empty_page_state.dart';
  10. import 'bloc/empty_page_repository.dart';
  11. class EmptyPage extends StatelessWidget {
  12. @override
  13. Widget build(BuildContext context) {
  14. return BlocProvider<EmptyPageBloc>(
  15. create: (_) => EmptyPageBloc(EmptyPageRepository())..add(EmptyPageInitEvent()),
  16. child: _EmptyPageContainer(),
  17. );
  18. }
  19. }
  20. class _EmptyPageContainer extends StatefulWidget {
  21. @override
  22. __EmptyPageContainerState createState() => __EmptyPageContainerState();
  23. }
  24. class __EmptyPageContainerState extends State<_EmptyPageContainer> {
  25. /// 返回 or 升级
  26. void _buttonClick(String text) {
  27. if(!EmptyUtil.isEmpty(text) && text == 'update'){
  28. // 更新
  29. AppUpdateUtil.updateApp(context, needToast: true, mustShowDialog: true);
  30. }else {
  31. // 返回
  32. Navigator.maybePop(context);
  33. }
  34. }
  35. @override
  36. Widget build(BuildContext context) {
  37. return BlocBuilder<EmptyPageBloc, EmptyPageState>(
  38. builder: (context, state) {
  39. if (state is EmptyPageLoadedState) {
  40. return _buildMainWidget(state?.model);
  41. }
  42. return _buildMainWidget(null);
  43. },
  44. );
  45. }
  46. Widget _buildMainWidget(EmptyPageModel model) {
  47. return Scaffold(
  48. backgroundColor: HexColor.fromHex(model?.bgColor ?? '#F9F9F9'),
  49. appBar: AppBar(
  50. brightness: Brightness.light,
  51. leading: IconButton(
  52. icon: Icon(
  53. Icons.arrow_back_ios,
  54. size: 22,
  55. color: HexColor.fromHex(model?.appBarNameColor ?? '#333333'),
  56. ),
  57. onPressed: () => Navigator.maybePop(context),
  58. ),
  59. backgroundColor: HexColor.fromHex('#FFFFFF'),
  60. centerTitle: true,
  61. title: Text(
  62. model?.appBarName ?? '开发中',
  63. style: TextStyle(fontSize: 15, color: HexColor.fromHex(model?.appBarNameColor ?? '#333333'), fontWeight: FontWeight.bold),
  64. ),
  65. elevation: 0,
  66. ),
  67. body: Padding(
  68. padding: const EdgeInsets.symmetric(horizontal: 36),
  69. child: Column(
  70. children: <Widget>[
  71. /// 图片
  72. Padding(
  73. padding: const EdgeInsets.only(top: 125),
  74. child: Container(
  75. height: 200,
  76. width: double.infinity,
  77. child: CachedNetworkImage(
  78. imageUrl: model?.bgImg ?? '',
  79. ),
  80. )),
  81. /// 提示文字
  82. Padding(
  83. padding: const EdgeInsets.only(top: 16, left: 30, right: 30),
  84. child: Text(
  85. model?.contentText ?? '程序员小哥正在开发中,敬请期待',
  86. maxLines: 2,
  87. textAlign: TextAlign.center,
  88. style: TextStyle(color: HexColor.fromHex(model?.contentTextColor ?? '#999999'), fontSize: 14),
  89. )),
  90. /// 按钮
  91. Padding(
  92. padding: const EdgeInsets.only(top: 16),
  93. child: GestureDetector(
  94. onTap: ()=>_buttonClick(model?.btnType),
  95. behavior: HitTestBehavior.opaque,
  96. child: Container(
  97. decoration: BoxDecoration(
  98. borderRadius: BorderRadius.circular(30),
  99. boxShadow: [
  100. BoxShadow(
  101. color: HexColor.fromHex('#FF2020'),
  102. blurRadius: 0.5,
  103. )
  104. ],
  105. gradient: LinearGradient(begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: [
  106. HexColor.fromHex(model?.btnColor1 ?? '#FF6868'),
  107. HexColor.fromHex(model?.btnColor2 ?? '#FF4242'),
  108. ])),
  109. padding: const EdgeInsets.symmetric(horizontal: 43, vertical: 7.5),
  110. child: Text(
  111. model?.btnText ?? '返回',
  112. style: TextStyle(color: HexColor.fromHex(model?.btnTextColor ?? '#FFFFFF'), fontSize: 13),
  113. ),
  114. ),
  115. ),
  116. )
  117. ],
  118. ),
  119. ),
  120. );
  121. }
  122. }