import 'package:ambito/src/entity/measure/measure_repository.dart';
import 'package:ambito/src/extensions/extensions.dart';
import 'package:flutter/material.dart';
import 'package:flutter_form_builder/flutter_form_builder.dart';

class AmbitoFormBuilder {
  String type = '';
  List<Widget> fields = [];

  Widget init(BuildContext context, String dbType) {
    MeasureRepository().buildLists();
    return get();
  }

  Widget get() {
    return FormBuilder(child: Column(children: fields));
  }

  _getField(BuildContext context, String type, String name) {}

  _getTextInputField(BuildContext context, String name) {
    return Padding(
      padding: const EdgeInsets.only(bottom: 40),
      child: FormBuilderTextField(
        name: name,
        decoration:
            InputDecoration(labelText: context.translate('fields.$type.$name')),
        obscureText: false,
      ),
    );
  }

  _getBoolInputField(BuildContext context, String name) {
    return Padding(
      padding: const EdgeInsets.only(bottom: 40),
      child: FormBuilderSwitch(
        name: name,
        title: Text(context.translate('fields.$type.$name')),
      ),
    );
  }

  _getDropdownField(BuildContext context, String name) {
    return Padding(
      padding: const EdgeInsets.only(bottom: 40),
      child: FormBuilderDropdown(
        name: name,
        decoration:
            InputDecoration(labelText: context.translate('fields.$type.$name')),
        items: [],
      ),
    );
  }
}
