import 'package:fis_i18n/i18n.dart';
import 'package:fis_jsonrpc/rpc.dart';
import 'package:fis_ui/index.dart';
import 'package:flutter/material.dart';

class FDeviceDetailInfo extends FStatelessWidget {
  const FDeviceDetailInfo({
    super.key,
    required this.deviceExtendInfo,
  });
  final DeviceExtendInfoDTO deviceExtendInfo;

  @override
  FWidget build(BuildContext context) {
    return FColumn(
      mainAxisAlignment: MainAxisAlignment.start,
      children: [
        _buildRowItem(
          value: deviceExtendInfo.shortCode ?? '',
          lable: i18nBook.user.deviceCode.t,
        ),
        _buildSizeBox(),
        _buildRowItem(
          value: deviceExtendInfo.deviceModel ?? '',
          lable: i18nBook.remoteControl.model.t,
        ),
        _buildSizeBox(),
        _buildRowItem(
          value: deviceExtendInfo.deviceSoftwareVersion ?? '',
          lable: i18nBook.remoteControl.softwareVersion.t,
        ),
        _buildSizeBox(),
        _buildRowItem(
          value: deviceExtendInfo.systemVersion ?? '',
          lable: i18nBook.remoteControl.systemVersion.t,
        ),
      ],
    );
  }

  FWidget _buildSizeBox() {
    if (kIsMobile) {
      return FSizedBox(
        height: 8,
      );
    }
    return FSizedBox(
      height: 15,
    );
  }

  FWidget _buildRowItem({
    required String lable,
    required String value,
  }) {
    return FRow(
      children: [
        FContainer(
          width: i18nBook.isCurrentChinese ? 65 : 83,
          child: FText(
            lable,
            style: TextStyle(color: Colors.white),
          ),
        ),
        FExpanded(
          child: FText(
            value,
            style: TextStyle(color: Colors.white),
          ),
        ),
      ],
    );
  }
}
