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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. brightness: Brightness.light,
  35. leading: IconButton(
  36. icon: Icon(
  37. Icons.arrow_back_ios,
  38. size: 22,
  39. color: HexColor.fromHex('#333333'),
  40. ),
  41. onPressed: () => _openPop(context),
  42. ),
  43. title: Text(
  44. model?.app_bar_title ?? '搜索',
  45. style: TextStyle(fontWeight: FontWeight.bold, color: HexColor.fromHex(model?.app_bar_title_color ?? '#333333')),
  46. ),
  47. centerTitle: true,
  48. );
  49. }
  50. }