forked from eatvio/eatvio_app
refactor(diary): Refactoring once more
This commit is contained in:
@@ -73,75 +73,73 @@ class CustomDropDown extends StatelessWidget {
|
||||
return alignment != null
|
||||
? Align(
|
||||
alignment: alignment ?? Alignment.center,
|
||||
child: dropDownWidget,
|
||||
child: _buildDropDownWidget(context),
|
||||
)
|
||||
: dropDownWidget;
|
||||
: _buildDropDownWidget(context);
|
||||
}
|
||||
|
||||
Widget get dropDownWidget => SizedBox(
|
||||
width: width ?? double.maxFinite,
|
||||
child: DropdownButtonFormField<SelectionPopupModel>(
|
||||
focusNode: focusNode ?? FocusNode(),
|
||||
icon: icon,
|
||||
autofocus: autofocus!,
|
||||
style: textStyle ?? theme.textTheme.titleMedium,
|
||||
items: items?.map((SelectionPopupModel item) {
|
||||
return DropdownMenuItem<SelectionPopupModel>(
|
||||
value: item,
|
||||
child: Text(
|
||||
item.title,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: hintStyle ?? theme.textTheme.titleMedium,
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
decoration: decoration,
|
||||
validator: validator,
|
||||
value: defaultValue,
|
||||
onChanged: (value) {
|
||||
onChanged!(value!);
|
||||
},
|
||||
),
|
||||
);
|
||||
InputDecoration get decoration => InputDecoration(
|
||||
hintText: hintText ?? "",
|
||||
hintStyle: hintStyle ?? theme.textTheme.titleMedium,
|
||||
prefixIcon: prefix,
|
||||
prefixIconConstraints: prefixConstraints,
|
||||
suffixIcon: suffix,
|
||||
suffixIconConstraints: suffixConstraints,
|
||||
isDense: true,
|
||||
contentPadding: contentPadding ??
|
||||
EdgeInsets.only(
|
||||
left: 6.h,
|
||||
top: 6.v,
|
||||
bottom: 6.v,
|
||||
_buildDropDownWidget(BuildContext context) {
|
||||
return SizedBox(
|
||||
width: width ?? double.maxFinite,
|
||||
child: DropdownButtonFormField<SelectionPopupModel>(
|
||||
focusNode: focusNode ?? FocusNode(),
|
||||
icon: icon,
|
||||
autofocus: autofocus!,
|
||||
style: textStyle ?? Theme.of(context).textTheme.titleMedium,
|
||||
items: items?.map((SelectionPopupModel item) {
|
||||
return DropdownMenuItem<SelectionPopupModel>(
|
||||
value: item,
|
||||
child: Text(
|
||||
item.title,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: hintStyle ?? Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
fillColor: fillColor ?? theme.colorScheme.onPrimary,
|
||||
filled: filled,
|
||||
border: borderDecoration ??
|
||||
OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(8.h),
|
||||
borderSide: BorderSide(
|
||||
color: Colors.grey,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
enabledBorder: borderDecoration ??
|
||||
OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(8.h),
|
||||
borderSide: BorderSide(
|
||||
color: Colors.grey,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
focusedBorder: borderDecoration ??
|
||||
OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(8.h),
|
||||
borderSide: BorderSide(
|
||||
color: Colors.grey,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
);
|
||||
);
|
||||
}).toList(),
|
||||
decoration: _buildInputDecoration(context),
|
||||
validator: validator,
|
||||
value: defaultValue,
|
||||
onChanged: onDropDownChanged,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void onDropDownChanged(value) {
|
||||
onChanged!(value!);
|
||||
}
|
||||
|
||||
InputDecoration _buildInputDecoration(BuildContext context) {
|
||||
return InputDecoration(
|
||||
hintText: hintText ?? "",
|
||||
hintStyle: hintStyle ?? Theme.of(context).textTheme.titleMedium,
|
||||
prefixIcon: prefix,
|
||||
prefixIconConstraints: prefixConstraints,
|
||||
suffixIcon: suffix,
|
||||
suffixIconConstraints: suffixConstraints,
|
||||
isDense: true,
|
||||
contentPadding: contentPadding ??
|
||||
EdgeInsets.only(
|
||||
left: 6,
|
||||
top: 6,
|
||||
bottom: 6,
|
||||
),
|
||||
fillColor: fillColor ?? Theme.of(context).colorScheme.onPrimary,
|
||||
filled: filled,
|
||||
border: borderDecoration ??
|
||||
OutlineInputBorder(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||
borderSide: BorderSide(color: Colors.grey, width: 1),
|
||||
),
|
||||
enabledBorder: borderDecoration ??
|
||||
OutlineInputBorder(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||
borderSide: BorderSide(color: Colors.grey, width: 1),
|
||||
),
|
||||
focusedBorder: borderDecoration ??
|
||||
OutlineInputBorder(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||
borderSide: BorderSide(color: Colors.grey, width: 1),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user