Skip to content

rf18 #192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft

rf18 #192

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pr-check-annotation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: 3.27.4
flutter-version: 3.32.2
channel: stable
cache: true
- name: Check out repository code
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-check-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: 3.27.4
flutter-version: 3.32.2
channel: stable
cache: true
- name: Check out repository code
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-check-generator-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: 3.27.4
flutter-version: 3.32.2
channel: stable
cache: true
- name: Check out repository code
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-check-generator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: 3.27.4
flutter-version: 3.32.2
channel: stable
cache: true
- name: Check out repository code
Expand Down
20 changes: 20 additions & 0 deletions packages/reactive_forms_annotations/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
## [8.0.1]

* bugfix

## [8.0.0]

* Rf18

## [8.0.0-beta0]

* Rf18

## [7.0.1]

* ReactiveFormArrayItemBuilder

## [7.0.0]

* v7 release

## [7.0.0-beta0]

* freezed 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export 'package:reactive_forms/src/widgets/reactive_form_pop_scope.dart';
export 'src/reactive_form_annotation.dart';
export 'src/form_group_annotation.dart';
export 'src/form_array_annotation.dart';
export 'src/form_array.dart';
export 'src/form_control_annotation.dart';
export 'src/form_model.dart';
export 'src/extended_control.dart';
69 changes: 69 additions & 0 deletions packages/reactive_forms_annotations/lib/src/form_array.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import 'package:flutter/material.dart';
import 'package:reactive_forms/reactive_forms.dart';

class ReactiveFormArrayItemBuilder<T> extends StatelessWidget {
const ReactiveFormArrayItemBuilder({
Key? key,
this.formControl,
this.builder,
required this.itemBuilder,
this.emptyBuilder,
this.controlFilter,
}) : super(key: key);

final FormArray<T>? formControl;

final Widget Function(BuildContext context, List<Widget> itemList)? builder;

final Widget Function(
BuildContext context,
int i,
FormControl<T> control,
T? item,
) itemBuilder;

final Widget Function(BuildContext context)? emptyBuilder;

final bool Function(FormControl<T> control)? controlFilter;

@override
Widget build(BuildContext context) {
return ReactiveFormArray<T>(
formArray: formControl,
builder: (context, formArray, child) {
final values = formArray.controls.indexed
.where((e) =>
controlFilter?.call(
e.$2 as FormControl<T>,
) ??
true)
.toList();

final itemList = values
.map((item) {
return MapEntry(
item.$1,
itemBuilder(
context,
item.$1,
formArray.controls[item.$1] as FormControl<T>,
item.$2.value,
),
);
})
.map((e) => e.value)
.toList();

if (emptyBuilder != null && itemList.isEmpty) {
return emptyBuilder!(context);
}

return builder?.call(
context,
itemList,
) ??
Column(children: itemList);
},
);
}
}
4 changes: 2 additions & 2 deletions packages/reactive_forms_annotations/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ name: reactive_forms_annotations
description: Annotations for reactive_forms_generator
repository: https://github.com/artflutter/reactive_forms_generator

version: 7.0.0-beta0
version: 8.0.1

environment:
sdk: ">=3.6.0 <4.0.0"
resolution: workspace

dependencies:
reactive_forms: ^17.0.0
reactive_forms: ^18.0.0
collection: ^1.18.0
logging: ^1.3.0
flutter:
Expand Down
32 changes: 32 additions & 0 deletions packages/reactive_forms_generator/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
## [8.0.1]

* bugfix

## [8.0.0]

* Rf18

## [8.0.0-beta0]

* Rf18

## [7.0.4]

* ReactiveFormArrayItemBuilder

## [7.0.3]

* fix

## [7.0.2]

* fix

## [7.0.1]

* array builder improvements

## [7.0.0]

* v7 release

## [7.0.0-beta4]

* bugfix
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class ReactiveAnimatedUrlListForm extends StatelessWidget {
required this.form,
required this.child,
this.canPop,
this.onPopInvoked,
this.onPopInvokedWithResult,
}) : super(key: key);

final Widget child;
Expand All @@ -63,7 +63,8 @@ class ReactiveAnimatedUrlListForm extends StatelessWidget {

final bool Function(FormGroup formGroup)? canPop;

final void Function(FormGroup formGroup, bool didPop)? onPopInvoked;
final ReactiveFormPopInvokedWithResultCallback<dynamic>?
onPopInvokedWithResult;

static AnimatedUrlListForm? of(
BuildContext context, {
Expand All @@ -90,7 +91,7 @@ class ReactiveAnimatedUrlListForm extends StatelessWidget {
stream: form.form.statusChanged,
child: ReactiveFormPopScope(
canPop: canPop,
onPopInvoked: onPopInvoked,
onPopInvokedWithResult: onPopInvokedWithResult,
child: child,
),
);
Expand All @@ -111,7 +112,7 @@ class AnimatedUrlListFormBuilder extends StatefulWidget {
this.model,
this.child,
this.canPop,
this.onPopInvoked,
this.onPopInvokedWithResult,
required this.builder,
this.initState,
}) : super(key: key);
Expand All @@ -122,7 +123,8 @@ class AnimatedUrlListFormBuilder extends StatefulWidget {

final bool Function(FormGroup formGroup)? canPop;

final void Function(FormGroup formGroup, bool didPop)? onPopInvoked;
final ReactiveFormPopInvokedWithResultCallback<dynamic>?
onPopInvokedWithResult;

final Widget Function(
BuildContext context, AnimatedUrlListForm formModel, Widget? child)
Expand Down Expand Up @@ -210,7 +212,7 @@ class _AnimatedUrlListFormBuilderState
child: ReactiveFormBuilder(
form: () => _formModel.form,
canPop: widget.canPop,
onPopInvoked: widget.onPopInvoked,
onPopInvokedWithResult: widget.onPopInvokedWithResult,
builder: (context, formGroup, child) =>
widget.builder(context, _formModel, widget.child),
child: widget.child,
Expand Down Expand Up @@ -879,45 +881,28 @@ class ReactiveAnimatedUrlListFormArrayBuilder<
throw FormControlParentNotFoundException(this);
}

return ReactiveFormArray<ReactiveAnimatedUrlListFormArrayBuilderT>(
formArray: formControl ?? control?.call(formModel),
builder: (context, formArray, child) {
final values = formArray.controls.indexed
.where((e) =>
controlFilter?.call(
e as FormControl<ReactiveAnimatedUrlListFormArrayBuilderT>,
) ??
true)
.toList();

final itemList = values
.map((item) {
return MapEntry(
item.$1,
itemBuilder(
context,
item.$1,
formArray.controls[item.$1]
as FormControl<ReactiveAnimatedUrlListFormArrayBuilderT>,
item.$2.value,
formModel,
),
);
})
.map((e) => e.value)
.toList();

if (emptyBuilder != null && itemList.isEmpty) {
return emptyBuilder!(context);
}

return builder?.call(
context,
itemList,
formModel,
) ??
Column(children: itemList);
},
final builder = this.builder;
final itemBuilder = this.itemBuilder;

return ReactiveFormArrayItemBuilder<
ReactiveAnimatedUrlListFormArrayBuilderT>(
formControl: formControl ?? control?.call(formModel),
builder: builder != null
? (context, itemList) => builder(
context,
itemList,
formModel,
)
: null,
itemBuilder: (
context,
i,
control,
item,
) =>
itemBuilder(context, i, control, item, formModel),
emptyBuilder: emptyBuilder,
controlFilter: controlFilter,
);
}
}
Expand Down Expand Up @@ -971,45 +956,34 @@ class ReactiveAnimatedUrlListFormArrayBuilder2<
throw FormControlParentNotFoundException(this);
}

return ReactiveFormArray<ReactiveAnimatedUrlListFormArrayBuilderT>(
formArray: formControl ?? control?.call(formModel),
builder: (context, formArray, child) {
final values = formArray.controls.indexed
.where((e) =>
controlFilter?.call(
e as FormControl<ReactiveAnimatedUrlListFormArrayBuilderT>,
) ??
true)
.toList();

final itemList = values
.map((item) {
return MapEntry(
item.$1,
itemBuilder((
context: context,
i: item.$1,
control: formArray.controls[item.$1]
as FormControl<ReactiveAnimatedUrlListFormArrayBuilderT>,
item: item.$2.value,
formModel: formModel
)),
);
})
.map((e) => e.value)
.toList();

if (emptyBuilder != null && itemList.isEmpty) {
return emptyBuilder!(context);
}

return builder?.call((
context: context,
itemList: itemList,
formModel: formModel,
)) ??
Column(children: itemList);
},
final builder = this.builder;
final itemBuilder = this.itemBuilder;

return ReactiveFormArrayItemBuilder<
ReactiveAnimatedUrlListFormArrayBuilderT>(
formControl: formControl ?? control?.call(formModel),
builder: builder != null
? (context, itemList) => builder((
context: context,
itemList: itemList,
formModel: formModel,
))
: null,
itemBuilder: (
context,
i,
control,
item,
) =>
itemBuilder((
context: context,
i: i,
control: control,
item: item,
formModel: formModel
)),
emptyBuilder: emptyBuilder,
controlFilter: controlFilter,
);
}
}
Expand Down
Loading
Loading