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

search_appbar_widget.dart 1.5 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import 'dart:convert';
  2. import 'package:flutter/material.dart';
  3. import 'package:zhiying_base_widget/widgets/search/appbar/model/search_appbar_model.dart';
  4. import 'dart:ui';
  5. import 'package:zhiying_comm/zhiying_comm.dart';
  6. class SearchAppbarWidget extends StatelessWidget {
  7. final Map<String, dynamic> data;
  8. SearchAppbarModel model;
  9. SearchAppbarWidget(this.data, {Key key}) : super(key: key) {
  10. try {
  11. model = SearchAppbarModel.fromJson(jsonDecode(data['data']));
  12. } catch (e) {
  13. Logger.error(e);
  14. }
  15. }
  16. /// 返回键
  17. void _openPop(BuildContext context) {
  18. Navigator.maybePop(context);
  19. }
  20. @override
  21. Widget build(BuildContext context) {
  22. return Container(
  23. width: double.infinity,
  24. color: HexColor.fromHex(model?.app_bar_bg_color ?? '#FFFFFF'),
  25. padding: EdgeInsets.only(top: MediaQueryData.fromWindow(window).padding.top),
  26. child: _getMainWidget(context),
  27. );
  28. }
  29. /// 样式1
  30. Widget _getMainWidget(BuildContext context) {
  31. return AppBar(
  32. backgroundColor: Colors.transparent,
  33. elevation: 0,
  34. leading: IconButton(
  35. icon: Icon(
  36. Icons.arrow_back_ios,
  37. size: 22,
  38. color: HexColor.fromHex('#333333'),
  39. ),
  40. onPressed: () => _openPop(context),
  41. ),
  42. title: Text(
  43. model?.app_bar_title ?? '搜索',
  44. style: TextStyle(fontWeight: FontWeight.bold, color: HexColor.fromHex(model?.app_bar_title_color ?? '#333333')),
  45. ),
  46. centerTitle: true,
  47. );
  48. }
  49. }