import 'package:ambito/src/widgets/form/form_widget_type.dart';
import 'package:flutter/material.dart';
import 'package:flutter_form_builder/flutter_form_builder.dart';

abstract class FormWidgetField {
  Widget get() {
    return FormBuilderTextField(name: '');
  }
}

class FormWidget extends StatelessWidget {
  FormWidget({super.key, required this.type, required this.fields});

  final _formKey = GlobalKey<FormBuilderState>();

  final FormWidgetType type;
  final List<FormWidgetField> fields;

  @override
  Widget build(BuildContext context) {
    return SizedBox(
        child: FormBuilder(
      key: _formKey,
      child: (type == FormWidgetType.vertical)
          ? Column(
              children: fields.map((element) => element.get()).toList(),
            )
          : Row(
              children: fields.map((element) => element.get()).toList(),
            ),
    ));
  }
}
