基础库
 
 
 
 
 

173 rindas
4.6 KiB

  1. import 'package:flutter/material.dart';
  2. import 'package:zhiying_comm/zhiying_comm.dart';
  3. import 'package:cached_network_image/cached_network_image.dart';
  4. ///
  5. /// 快速登陆
  6. ///
  7. class LoginQuickPage extends StatelessWidget {
  8. final Map<String, dynamic> model;
  9. const LoginQuickPage(this.model, {Key key}) : super(key: key);
  10. @override
  11. Widget build(BuildContext context) {
  12. return Scaffold(
  13. backgroundColor: Colors.white,
  14. body: LoginQuickContainerPage(),
  15. );
  16. }
  17. }
  18. class LoginQuickContainerPage extends StatefulWidget {
  19. @override
  20. _LoginQuickContainerPageState createState() => _LoginQuickContainerPageState();
  21. }
  22. class _LoginQuickContainerPageState extends State<LoginQuickContainerPage> {
  23. /// 登陆事件
  24. void _submitOnClick() {
  25. print('点击登陆');
  26. }
  27. /// 切换账号
  28. void _changeAccount() {
  29. print('切换账号');
  30. }
  31. /// 同意or取消用户协议
  32. void _agree(){
  33. }
  34. final _sizedBoxHeight30 = const SizedBox(height: 30);
  35. final _sizedBoxHeight35 = const SizedBox(height: 35);
  36. final _sizedBoxHeight20 = const SizedBox(height: 20);
  37. final _sizedBoxHeight16 = const SizedBox(height: 16);
  38. final _sizedBoxHeight28 = const SizedBox(height: 28);
  39. @override
  40. Widget build(BuildContext context) {
  41. return Column(
  42. mainAxisAlignment: MainAxisAlignment.center,
  43. children: <Widget>[
  44. /// appbar
  45. _getAppBarWidget(),
  46. _sizedBoxHeight30,
  47. /// logo
  48. _getLogoWidget(null),
  49. _sizedBoxHeight35,
  50. /// 账号
  51. _getAccountWidget(null),
  52. // _sizedBoxHeight20,
  53. /// 切换账号提示
  54. _changeAccountTipWidget(null),
  55. // _sizedBoxHeight20,
  56. /// 登陆按钮
  57. _submitButton(null),
  58. _sizedBoxHeight16,
  59. /// 协议
  60. _protocolWidget(null),
  61. /// 底部tip
  62. Expanded(
  63. child: Align(
  64. child: _bottomTipWidget(null),
  65. alignment: Alignment.bottomCenter,
  66. ),
  67. )
  68. ],
  69. );
  70. }
  71. /// 底部提示
  72. Widget _bottomTipWidget(var model) {
  73. return Container(
  74. margin: const EdgeInsets.only(bottom: 28), child: Text('中国电信提供认证服务', style: TextStyle(fontSize: 11, color: HexColor.fromHex('#C0C0C0'))));
  75. }
  76. /// 协议
  77. Widget _protocolWidget(var model) {
  78. return Container(
  79. child: Text('《嗨如意用户协议》', style: TextStyle(fontSize: 11, color: HexColor.fromHex('#C0C0C0'))),
  80. );
  81. }
  82. /// 立即登陆按钮
  83. Widget _submitButton(var model) {
  84. return Material(
  85. child: Container(
  86. height: 52,
  87. width: double.infinity,
  88. color: Colors.white,
  89. padding: const EdgeInsets.symmetric(horizontal: 27.5),
  90. child: RaisedButton(
  91. child: Text(
  92. '立即登录',
  93. style: TextStyle(fontSize: 15),
  94. ),
  95. textColor: HexColor.fromHex('#FFFFFF'),
  96. color: HexColor.fromHex('#FF3939'),
  97. disabledColor: HexColor.fromHex('#F5F5F5'),
  98. disabledTextColor: HexColor.fromHex('#999999'),
  99. elevation: 5,
  100. shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(52 / 2)),
  101. onPressed: _submitOnClick,
  102. ),
  103. ),
  104. );
  105. }
  106. /// 切换账号提示
  107. Widget _changeAccountTipWidget(var model) {
  108. return GestureDetector(
  109. behavior: HitTestBehavior.opaque,
  110. onTap: () => _changeAccount(), child: Container( margin: const EdgeInsets.symmetric(vertical: 20), child: Text('切换账号', style: TextStyle(fontSize: 13, color: HexColor.fromHex('#FF3939')))));
  111. }
  112. /// 账号
  113. Widget _getAccountWidget(var model) {
  114. return Text('158****3158', style: TextStyle(fontSize: 25, color: HexColor.fromHex('#333333')));
  115. }
  116. /// login
  117. Widget _getLogoWidget(var model) {
  118. return Container(
  119. margin: EdgeInsets.only(bottom: 12, top: MediaQuery.of(context).padding.top),
  120. decoration: BoxDecoration(
  121. borderRadius: BorderRadius.circular(14),
  122. boxShadow: [
  123. BoxShadow(color: Colors.grey[300], offset: Offset(0.0, 0.0), blurRadius: 10.0, spreadRadius: 1.0),
  124. BoxShadow(color: Colors.grey[300], offset: Offset(0.0, 0.0)),
  125. ],
  126. ),
  127. height: 80,
  128. width: 80,
  129. child: CachedNetworkImage(
  130. imageUrl: model?.logoImg ?? '',
  131. fit: BoxFit.fill,
  132. ),
  133. );
  134. }
  135. /// appBar
  136. Widget _getAppBarWidget() {
  137. return AppBar(
  138. brightness: Brightness.light,
  139. backgroundColor: Colors.transparent,
  140. elevation: 0,
  141. leading: Icon(
  142. Icons.arrow_back_ios,
  143. size: 22,
  144. color: HexColor.fromHex('#333333'),
  145. ),
  146. );
  147. }
  148. }