Skip to content

Commit

Permalink
reactive_dropdown_button2 1.0.0-beta.10
Browse files Browse the repository at this point in the history
  • Loading branch information
vasilich6107 committed Mar 12, 2024
1 parent ecba55e commit 97f7ec2
Show file tree
Hide file tree
Showing 21 changed files with 673 additions and 108 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>9.0</string>
<string>11.0</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 50;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -127,7 +127,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1300;
LastUpgradeCheck = 1430;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down Expand Up @@ -171,10 +171,12 @@
/* Begin PBXShellScriptBuildPhase section */
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}",
);
name = "Thin Binary";
outputPaths = (
Expand All @@ -185,6 +187,7 @@
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
Expand Down Expand Up @@ -272,7 +275,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down Expand Up @@ -346,7 +349,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -395,7 +398,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
LastUpgradeVersion = "1430"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 2 additions & 0 deletions packages/reactive_color_picker/example/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,7 @@
<false/>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
</dict>
</plist>
13 changes: 13 additions & 0 deletions packages/reactive_dropdown_button2/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
## 1.0.0-beta.10

* upgrade control value accessor to have ability to map against `items`

## 0.0.4-beta.10

* more styling options

## 0.0.3-beta.10

* wrapper for v3 beta.10
* fix for disabled property

## 0.0.3-beta.6

* wrapper for v3 beta.6
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>11.0</string>
<string>12.0</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down Expand Up @@ -473,7 +473,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -522,7 +522,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down
215 changes: 206 additions & 9 deletions packages/reactive_dropdown_button2/example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:collection/collection.dart';
import 'package:reactive_dropdown_button2/reactive_dropdown_button2.dart';
import 'package:reactive_forms/reactive_forms.dart';

Expand All @@ -17,17 +18,53 @@ final List<String> items = [
'Item8',
];

final List<({int id, String value})> itemsRecord = [
(id: 1, value: 'Item1'),
(id: 2, value: 'Item2'),
(id: 3, value: 'Item3'),
(id: 4, value: 'Item4'),
(id: 5, value: 'Item5'),
(id: 6, value: 'Item6'),
(id: 7, value: 'Item7'),
(id: 8, value: 'Item8'),
];

class Drop extends DropDownValueAccessor<int, ({int id, String value})> {
@override
({int id, String value})? modelToViewValue(List<DropdownItem<({int id, String value})>> items, int? modelValue) {
return items.firstWhereOrNull((e) => e.value?.id == modelValue)?.value;
}

@override
int? viewToModelValue(List<DropdownItem<({int id, String value})>> items, ({int id, String value})? modelValue) {
return modelValue?.id;
}

}

const icon = Icon(
Icons.access_alarms,
size: 24,
);
const hint = Text('Hint text');

class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);

FormGroup buildForm() => fb.group({
'input': FormControl<String>(
value: null,
validators: [
const RequiredValidator(),
],
),
});
'input': FormControl<String>(
value: null,
validators: [
const RequiredValidator(),
],
),
'input2': FormControl<int>(
value: null,
validators: [
const RequiredValidator(),
],
),
});

@override
Widget build(BuildContext context) {
Expand All @@ -50,7 +87,6 @@ class MyApp extends StatelessWidget {
builder: (context, form, child) {
return Column(
children: [
const Text('Test'),
const SizedBox(height: 16),
DropdownButtonHideUnderline(
child: ReactiveDropdownButton2<String, String>(
Expand All @@ -77,7 +113,6 @@ class MyApp extends StatelessWidget {
),
elevation: 2,
),

iconStyleData: const IconStyleData(
icon: Icon(
Icons.arrow_forward_ios_outlined,
Expand Down Expand Up @@ -105,9 +140,171 @@ class MyApp extends StatelessWidget {
),
),
),
const SizedBox(height: 16),
ReactiveDropdownButton2<int, ({int id, String value})>(
formControlName: 'input2',
valueAccessor: Drop(),
isExpanded: true,
inputDecoration: const InputDecoration(
border: InputBorder.none,
enabledBorder: InputBorder.none,
errorBorder: InputBorder.none,
contentPadding: EdgeInsets.zero,
helperText: "",
helperStyle: TextStyle(height: 0.8),
errorStyle: TextStyle(height: 0.8),
),
items: itemsRecord
.map(
(({int id, String value}) item) => DropdownItem<({int id, String value})>(
value: item,
child: Row(
children: [
const SizedBox.square(dimension: 40,),
Text(item.value),
],
),
),
)
.toList(),
hint: Row(
children: [
const SizedBox.square(
dimension: 40,
child: icon,
),
const SizedBox(width: 12),
Expanded(
child: DefaultTextStyle.merge(
style: const TextStyle(
fontSize: 14.0,
height: 1.8,
),
overflow: TextOverflow.ellipsis,
child: hint,
),
),
],
),
underline: const SizedBox.shrink(),
errorButtonStyleData: ButtonStyleData(
height: 48,
padding: const EdgeInsets.only(right: 8),
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(
color: Theme.of(context).colorScheme.error),
borderRadius: const BorderRadius.all(
Radius.circular(12),
),
),
),
buttonStyleData: ButtonStyleData(
height: 48,
padding: const EdgeInsets.only(right: 8),
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(color: const Color(0xFFBCC2CE)),
borderRadius: const BorderRadius.all(
Radius.circular(12),
),
),
),
iconStyleData: const IconStyleData(
icon: Icon(Icons.arrow_drop_down),
iconEnabledColor: Colors.black,
iconDisabledColor: Colors.grey,
openMenuIcon: Icon(Icons.arrow_drop_up),
),
errorBuilder: (_, error) => Padding(
padding: const EdgeInsets.symmetric(horizontal: 12),
child: Text(
error,
style: const TextStyle(height: 0.8),
),
),
disabledHint: Row(
children: [
SizedBox.square(
dimension: 24,
child: Builder(
builder: (context) {
final color =
DefaultTextStyle.of(context).style.color;


return IconTheme(
data: IconTheme.of(context).copyWith(
color: color,
size: 16,
),
child: icon,
);
},
),
),
const SizedBox(width: 12),
const Text(''),
],
),
selectedItemBuilder: (_) {
return items.map(
(value) {
return DropdownMenuItem<String>(
alignment: Alignment.centerLeft,
value: value,
child: Row(
children: [
SizedBox.square(
dimension: 40,
child: Center(
child: Builder(
builder: (context) {
final color =
DefaultTextStyle.of(context)
.style
.color;

return IconTheme(
data:
IconTheme.of(context).copyWith(
color: color,
size: 24,
),
child: icon,
);
},
),
),
),
Expanded(
child: Text(
value,
overflow: TextOverflow.ellipsis,
),
),
],
),
);
},
).toList();
},
dropdownStyleData: DropdownStyleData(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
),
padding: EdgeInsets.zero,
maxHeight: 300,
),
menuItemStyleData: const MenuItemStyleData(
padding: EdgeInsets.symmetric(horizontal: 0),
),
),
const SizedBox(height: 16),
ElevatedButton(
child: const Text('Submit'),
onPressed: () {
form.markAllAsTouched();
if (form.valid) {
debugPrint(form.value.toString());
}
Expand Down
Loading

0 comments on commit 97f7ec2

Please sign in to comment.