import 'package:flutter/material.dart';
import 'package:flut/flut/runtime.dart';
import 'package:flut/flut/object.dart';

class FlutBorderStyle extends FlutEnumObject<BorderStyle> {
  const FlutBorderStyle()
    : super('BorderStyle', const {
        'solid': BorderStyle.solid,
        'none': BorderStyle.none,
      });
}

class FlutBorderSide extends FlutImmutableObject {
  final BorderSide borderSide;

  const FlutBorderSide(this.borderSide) : super('BorderSide');

  @override
  Map<String, dynamic> flutEncode() => flutBaseProps();

  static BorderSide? flutDecode(
    FlutRuntime runtime,
    Map<String, dynamic> data,
  ) {
    return BorderSide(
      color: runtime.unpackRequiredField<Color>(data, 'color'),
      width: runtime.unpackRequiredField<double>(data, 'width'),
      style: runtime.unpackRequiredField<BorderStyle>(data, 'style'),
    );
  }
}

class FlutBorder extends FlutImmutableObject {
  final Border border;

  const FlutBorder(this.border) : super('Border');

  @override
  Map<String, dynamic> flutEncode() => flutBaseProps();

  static Border? flutDecode(FlutRuntime runtime, Map<String, dynamic> data) {
    return Border(
      top: runtime.unpackRequiredField<BorderSide>(data, 'top'),
      right: runtime.unpackRequiredField<BorderSide>(data, 'right'),
      bottom: runtime.unpackRequiredField<BorderSide>(data, 'bottom'),
      left: runtime.unpackRequiredField<BorderSide>(data, 'left'),
    );
  }
}
