app_city_search_bar.dart 5.3 KB

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