common_widget.dart 1.9 KB

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