app_city_search_bar.dart 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/services.dart';
  3. import 'package:liftmanager/routers/fluro_navigator.dart';
  4. import 'package:liftmanager/internal/search/search_router.dart';
  5. import 'package:liftmanager/res/colors.dart';
  6. import 'package:liftmanager/res/dimens.dart';
  7. import 'package:liftmanager/res/gaps.dart';
  8. import 'package:liftmanager/utils/theme_utils.dart';
  9. import 'package:liftmanager/widgets/load_image.dart';
  10. import 'package:liftmanager/internal/wode/wode_router.dart';
  11. import 'package:flustars/flustars.dart' as FlutterStars;
  12. import 'package:liftmanager/common/common.dart';
  13. import 'package:liftmanager/internal/account/account_router.dart';
  14. import 'package:liftmanager/utils/toast.dart';
  15. /// 自定义AppBar
  16. class AppCitySearchAppBar extends StatelessWidget
  17. implements PreferredSizeWidget {
  18. const AppCitySearchAppBar(
  19. {Key key,
  20. this.city: "",
  21. this.centerTitle: "",
  22. this.actionName: "",
  23. this.actionIcon: "",
  24. this.backImg: "assets/images/icon_back.png",
  25. this.onPressed,
  26. this.isBack: true,
  27. this.display: true,
  28. })
  29. : super(key: key);
  30. final String city;
  31. final String centerTitle;
  32. final String backImg;
  33. final String actionName;
  34. final String actionIcon;
  35. final VoidCallback onPressed;
  36. final bool isBack;
  37. final bool display;
  38. @override
  39. Widget build(BuildContext context) {
  40. double width = MediaQuery.of(context).size.width;
  41. return AnnotatedRegion<SystemUiOverlayStyle>(
  42. value: SystemUiOverlayStyle.light,
  43. child: Container(
  44. decoration: BoxDecoration(
  45. gradient: const LinearGradient(
  46. colors: [Color(0xFF00D9FF), Color(0xFF0287FF)]),
  47. ),
  48. // child: Material(
  49. //// color: _backgroundColor,
  50. // color: Colors.red,
  51. // shadowColor: Colors.amber,
  52. child: SafeArea(
  53. child: Stack(
  54. alignment: Alignment.centerLeft,
  55. children: <Widget>[
  56. Column(
  57. mainAxisAlignment: MainAxisAlignment.center,
  58. children: <Widget>[
  59. Container(
  60. alignment: Alignment.centerLeft,
  61. width: double.infinity,
  62. child: Text(city,
  63. overflow: TextOverflow.ellipsis,
  64. style: TextStyle(
  65. fontSize: Dimens.font_sp16, color: Colors.white)),
  66. padding: const EdgeInsets.symmetric(horizontal: 15.0),
  67. ),
  68. ],
  69. ),
  70. // Column(
  71. // mainAxisAlignment: MainAxisAlignment.center,
  72. // children: <Widget>[
  73. // Container(
  74. // padding: const EdgeInsets.only(left: 50.0),
  75. // child: Icon(
  76. // Icons.keyboard_arrow_down,
  77. // size: 20,
  78. // color: Colors.white,
  79. // )),
  80. // ],
  81. // ),
  82. GestureDetector(
  83. onTap: () {
  84. if(FlutterStars.SpUtil.getString(Constant.userId) == "-1"){
  85. toasts("请登录");
  86. NavigatorUtils.push(context, AccountRouter.loginPage, clearStack: true);
  87. }else {
  88. NavigatorUtils.push(context, SearchRouter.searchPage);
  89. }
  90. },
  91. child: Container(
  92. height: 35,
  93. width: width*0.65,
  94. margin: const EdgeInsets.only(left: 85.0, right: 15),
  95. decoration: BoxDecoration(
  96. color: Color(0x33FFFFFF),
  97. borderRadius: BorderRadius.circular(17.5)),
  98. child: Row(
  99. crossAxisAlignment: CrossAxisAlignment.center,
  100. mainAxisAlignment: MainAxisAlignment.start,
  101. children: <Widget>[
  102. SizedBox(
  103. width: 16,
  104. ),
  105. Icon(
  106. Icons.search,
  107. color: Colors.white,
  108. ),
  109. Text(
  110. "搜索你想要的关键词",
  111. style: TextStyle(color: Colors.white),
  112. )
  113. ],
  114. ),
  115. )),
  116. GestureDetector(
  117. onTap: (){
  118. if(FlutterStars.SpUtil.getString(Constant.userId) == "-1"){
  119. toasts("请登录");
  120. NavigatorUtils.push(context, AccountRouter.loginPage, clearStack: true);
  121. }else {
  122. NavigatorUtils.push(context, WodeRouter.noticeList);
  123. }
  124. },
  125. child: Container(
  126. alignment:Alignment.centerRight,
  127. padding: EdgeInsets.only(right:6),
  128. child:Stack(
  129. children: <Widget>[
  130. Icon(
  131. IconData(
  132. 0xe64f,
  133. fontFamily:"myfont"
  134. ),
  135. size: 26.0,
  136. color:Color.fromRGBO(255, 255, 255, 1),
  137. ),
  138. Positioned(
  139. child: (
  140. RedCirle(display:display)
  141. ),
  142. top:0,
  143. right:0
  144. ),
  145. ],
  146. )
  147. ),
  148. ),
  149. ],
  150. ),
  151. ),
  152. // ),
  153. ),
  154. );
  155. }
  156. @override
  157. Size get preferredSize => Size.fromHeight(48.0);
  158. }
  159. class RedCirle extends StatelessWidget {
  160. final bool display;
  161. const RedCirle(
  162. {
  163. Key key,
  164. this.display:true,
  165. })
  166. : super(key: key);
  167. @override
  168. Widget build(BuildContext context) {
  169. return Offstage(
  170. offstage: display,
  171. child:Container(
  172. width:6,
  173. height:6,
  174. decoration: BoxDecoration(
  175. borderRadius: BorderRadius.circular(3.0),
  176. color: Colors.red,
  177. ),
  178. )
  179. );
  180. }
  181. }