123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- import 'package:flustars/flustars.dart' as FlutterStars;
- import 'package:flutter/material.dart';
- import 'package:flutter/services.dart';
- import 'package:liftmanager/common/common.dart';
- import 'package:liftmanager/internal/account/account_router.dart';
- import 'package:liftmanager/internal/search/search_router.dart';
- import 'package:liftmanager/internal/wode/wode_router.dart';
- import 'package:liftmanager/res/iconfont.dart';
- import 'package:liftmanager/routers/fluro_navigator.dart';
- import 'package:liftmanager/utils/toast.dart';
- /// 自定义AppBar
- class AppCitySearchAppBar extends StatelessWidget
- implements PreferredSizeWidget {
- const AppCitySearchAppBar({
- Key key,
- this.city: "",
- this.centerTitle: "",
- this.actionName: "",
- this.actionIcon: "",
- this.backImg: "assets/images/icon_back.png",
- this.onPressed,
- this.isBack: true,
- this.display: true,
- }) : super(key: key);
- final String city;
- final String centerTitle;
- final String backImg;
- final String actionName;
- final String actionIcon;
- final VoidCallback onPressed;
- final bool isBack;
- final bool display;
- @override
- Widget build(BuildContext context) {
- double width = MediaQuery.of(context).size.width;
- return AnnotatedRegion<SystemUiOverlayStyle>(
- value: SystemUiOverlayStyle.light,
- child: Container(
- decoration: BoxDecoration(
- gradient: const LinearGradient(
- colors: [Color(0xFF00ACFF), Color(0xFF5888FF)]),
- ),
- child: SafeArea(
- child: Stack(
- alignment: Alignment.centerLeft,
- children: <Widget>[
- Row(children: [
- SizedBox(
- width: 10,
- ),
- Icon(
- Iconfont.dingwei,
- color: Colors.white,
- size: 18,
- ),
- Text(city,
- overflow: TextOverflow.ellipsis,
- style: TextStyle(
- fontSize: 12, color: Colors.white)),
- ]),
- GestureDetector(
- onTap: () {
- if (FlutterStars.SpUtil.getString(Constant.userId) ==
- "-1") {
- toasts("请登录");
- NavigatorUtils.push(context, AccountRouter.loginPage,
- clearStack: true);
- } else {
- NavigatorUtils.push(context, SearchRouter.searchPage);
- }
- },
- child: Container(
- height: 35,
- width: width * 0.65,
- margin: const EdgeInsets.only(left: 85.0, right: 15),
- decoration: BoxDecoration(
- color: Color(0x33FFFFFF),
- borderRadius: BorderRadius.circular(17.5)),
- child: Row(
- crossAxisAlignment: CrossAxisAlignment.center,
- mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget>[
- // SizedBox(
- // width: 16,
- // ),
- Icon(
- Iconfont.sousuo,
- color: Colors.white,
- size: 16,
- ),
- SizedBox(
- width: 10,
- ),
- Text(
- "输入搜索内容",
- style: TextStyle(color: Colors.white, fontSize: 14),
- )
- ],
- ),
- )),
- GestureDetector(
- onTap: () {
- if (FlutterStars.SpUtil.getString(Constant.userId) == "-1") {
- toasts("请登录");
- NavigatorUtils.push(context, AccountRouter.loginPage,
- clearStack: true);
- } else {
- NavigatorUtils.push(context, WodeRouter.messageCenter);
- }
- },
- child: Container(
- alignment: Alignment.centerRight,
- margin: EdgeInsets.only(right: 10),
- child: Stack(
- children: <Widget>[
- Icon(
- Iconfont.xiaoxi,
- color: Colors.white,
- size: 18,
- ),
- Positioned(
- child: (RedCirle(display: display)),
- top: 0,
- right: 0),
- ],
- )),
- ),
- ],
- ),
- ),
- // ),
- ),
- );
- }
- @override
- Size get preferredSize => Size.fromHeight(48.0);
- }
- class RedCirle extends StatelessWidget {
- final bool display;
- const RedCirle({
- Key key,
- this.display: true,
- }) : super(key: key);
- @override
- Widget build(BuildContext context) {
- return Offstage(
- offstage: display,
- child: Container(
- width: 6,
- height: 6,
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(3.0),
- color: Colors.red,
- ),
- ));
- }
- }
|