基础组件库
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 

57 wiersze
1.5 KiB

  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. }