preview_operation_view.dart 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_screenutil/flutter_screenutil.dart';
  3. import '../../../funcs.dart';
  4. import '../../../widget/operation_button.dart';
  5. ///预览操作视图
  6. class PreviewOperationView extends StatelessWidget {
  7. final void Function() onSave;
  8. final void Function() onCancel;
  9. const PreviewOperationView(
  10. {super.key, required this.onSave, required this.onCancel});
  11. @override
  12. Widget build(BuildContext context) {
  13. return OrientationBuilder(builder: (ctx, orientation) {
  14. Alignment alignment = orientation == Orientation.landscape
  15. ? Alignment.centerRight
  16. : Alignment.bottomCenter;
  17. //保存按钮
  18. Widget buttonSave = OperationButton(
  19. text: getS().save,
  20. onTap: onSave,
  21. child: const Icon(
  22. Icons.save,
  23. color: Colors.white,
  24. ));
  25. //取消按钮
  26. Widget buttonCancel = OperationButton(
  27. text: getS().retakePhoto,
  28. onTap: onCancel,
  29. child: const Icon(
  30. Icons.close,
  31. color: Colors.white,
  32. ));
  33. //根据横竖屏显示在不同位置
  34. return Align(
  35. alignment: alignment,
  36. child: Container(
  37. padding: orientation == Orientation.landscape
  38. ? EdgeInsets.only(right: 20.w)
  39. : EdgeInsets.only(bottom: 52.h),
  40. child: orientation == Orientation.landscape
  41. ? Column(
  42. mainAxisSize: MainAxisSize.min,
  43. children: [
  44. buttonSave,
  45. SizedBox(
  46. height: 40.h,
  47. ),
  48. buttonCancel,
  49. ],
  50. )
  51. : Row(
  52. mainAxisSize: MainAxisSize.min,
  53. children: [
  54. buttonSave,
  55. SizedBox(
  56. width: 44.w,
  57. ),
  58. buttonCancel,
  59. ],
  60. ),
  61. ),
  62. );
  63. });
  64. }
  65. }