common_view.dart 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter_screenutil/flutter_screenutil.dart';
  4. import '../resource/assets.gen.dart';
  5. import '../resource/colors.gen.dart';
  6. class CommonView {
  7. static Widget getBackBtnView() {
  8. return Container(
  9. padding: EdgeInsets.all(3.w),
  10. decoration: BoxDecoration(
  11. color: Colors.white,
  12. borderRadius: BorderRadius.all(Radius.circular(10.w))),
  13. child: Assets.images.iconBlackBack.image(width: 24.w, height: 24.w));
  14. }
  15. static Widget buildAppBar(String title,
  16. {VoidCallback? backOnTap, Widget? rightWidget, bool titleCenter = true}) {
  17. return Container(
  18. width: double.infinity,
  19. padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 14.w),
  20. child: Stack(
  21. children: [
  22. GestureDetector(onTap: backOnTap, child: CommonView.getBackBtnView()),
  23. Positioned(
  24. left: titleCenter ? 0 : 40.w,
  25. right: titleCenter ? 0 : null,
  26. top: 0,
  27. bottom: 0,
  28. child: Center(
  29. child: Text(title,
  30. style: TextStyle(
  31. height: 1,
  32. fontSize: 16.sp,
  33. color: ColorName.black90,
  34. fontWeight: FontWeight.bold)),
  35. ),
  36. ),
  37. if (rightWidget != null)
  38. Positioned(
  39. right: 0,
  40. top: 0,
  41. bottom: 0,
  42. child: rightWidget,
  43. )
  44. ],
  45. ),
  46. );
  47. }
  48. }