import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import '../../../funcs.dart';
import '../../../widget/operation_button.dart';

///查看历史操作视图
class HistoryViewOperationView extends StatelessWidget {
  final void Function() onUpload;
  final void Function() onDelete;

  const HistoryViewOperationView(
      {super.key, required this.onUpload, required this.onDelete});

  @override
  Widget build(BuildContext context) {
    return OrientationBuilder(builder: (ctx, orientation) {
      Alignment alignment = orientation == Orientation.landscape
          ? Alignment.centerRight
          : Alignment.bottomCenter;
      //上传按钮
      Widget buttonUpload = OperationButton(
          text: getS().upload,
          onTap: onUpload,
          child: const Icon(
            Icons.file_upload_outlined,
            color: Colors.white,
          ));

      //删除按钮
      Widget buttonDelete = OperationButton(
          text: getS().delete,
          onTap: onDelete,
          child: const Icon(
            Icons.close,
            color: Colors.white,
          ));

      //根据横竖屏显示在不同位置
      return Align(
        alignment: alignment,
        child: Container(
          padding: orientation == Orientation.landscape
              ? EdgeInsets.only(right: 20.w)
              : EdgeInsets.only(bottom: 52.h),
          child: orientation == Orientation.landscape
              ? Column(
                  mainAxisSize: MainAxisSize.min,
                  children: [
                    buttonUpload,
                    SizedBox(
                      height: 40.h,
                    ),
                    buttonDelete,
                  ],
                )
              : Row(
                  mainAxisSize: MainAxisSize.min,
                  children: [
                    buttonUpload,
                    SizedBox(
                      width: 44.w,
                    ),
                    buttonDelete,
                  ],
                ),
        ),
      );
    });
  }
}
