common_widget.dart 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import 'package:flutter/material.dart';
  2. import 'package:ftrecruiter/generated/assets.dart';
  3. import 'package:get/get.dart';
  4. import 'package:ftrecruiter/comm/constants/color_constants.dart';
  5. import 'package:ftrecruiter/comm/widget/my_load_image.dart';
  6. import 'package:ftrecruiter/comm/utils/dark_theme_util.dart';
  7. import 'package:ftrecruiter/local/theme/theme_config.dart';
  8. class CommonWidget {
  9. //封装AppBar
  10. static AppBar appBar(BuildContext context, String title,
  11. {void Function()? backCallback,
  12. String? backPath,
  13. Color textColor = Colors.black,
  14. Color backgroundColor = Colors.white,
  15. List<Widget>? actions}) {
  16. return AppBar(
  17. leading: Container(
  18. padding: const EdgeInsets.only(top: 3.5),
  19. child: IconButton(
  20. icon: Get.isDarkMode
  21. ? MyAssetImage(backPath ?? Assets.imagesWhiteBack, width: 22, height: 22)
  22. : MyAssetImage(backPath ?? Assets.imagesBlackBack, width: 22, height: 22),
  23. onPressed: () {
  24. if (backCallback != null) {
  25. backCallback();
  26. } else {
  27. Get.back();
  28. // Navigator.pop(context);
  29. }
  30. },
  31. ),
  32. ),
  33. centerTitle: true,
  34. title: Text(
  35. title,
  36. style: TextStyle(color: Get.isDarkMode ? Colors.white : textColor, fontSize: 18, fontWeight: FontWeight.w500),
  37. ),
  38. actions: actions,
  39. backgroundColor: DarkThemeUtil.multiColors(backgroundColor),
  40. elevation: 0.0,
  41. bottom: const PreferredSize(
  42. preferredSize: Size.fromHeight(0.5),
  43. child: Divider(
  44. height: 1.0,
  45. indent: 0.0,
  46. color: ColorConstants.dividerColor,
  47. )),
  48. );
  49. }
  50. //自定义高度快
  51. static SizedBox rowHeight({double height = 30}) {
  52. return SizedBox(height: height);
  53. }
  54. //自定义宽度快
  55. static SizedBox rowWidth({double width = 30}) {
  56. return SizedBox(width: width);
  57. }
  58. }