Skip to content

Commit

Permalink
to test nasted form builder
Browse files Browse the repository at this point in the history
  • Loading branch information
geaquzzil committed Oct 10, 2024
1 parent 4fdcf5b commit 1e0bfe8
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 30 deletions.
101 changes: 71 additions & 30 deletions flutter_views/lib/components/custom_tile_expansion.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import 'package:flutter_view_controller/constants.dart';
const Duration _kExpand = Duration(milliseconds: 200);

class ExpansionEdit extends StatefulWidget {



final bool initiallyExpanded;

/// Typically used to force the expansion arrow icon to the tile's leading or trailing edge.
Expand All @@ -23,7 +26,7 @@ class ExpansionEdit extends StatefulWidget {
/// When false (default), the children are removed from the tree when the tile is
/// collapsed and recreated upon expansion.
final bool maintainState;

final bool isNullable;
final Widget? leading;
final Widget title;
final Widget? subtitle;
Expand All @@ -33,7 +36,8 @@ class ExpansionEdit extends StatefulWidget {
super.key,
this.initiallyExpanded = false,
this.controlAffinity,
this.maintainState = false,
this.isNullable = false,
this.maintainState = true,
this.leading,
required this.title,
this.subtitle,
Expand Down Expand Up @@ -67,6 +71,9 @@ class _ExpansionEditState extends State<ExpansionEdit>
late Animation<Color?> _iconColor;
late Animation<Color?> _backgroundColor;

bool canExpand = true;
bool _isNullPressed = false;

bool _isExpanded = false;
Timer? _timer;

Expand Down Expand Up @@ -153,11 +160,12 @@ class _ExpansionEditState extends State<ExpansionEdit>
_borderTween
..begin = const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(kBorderRadius)))
..end = RoundedRectangleBorder(
side: BorderSide(
width: 1,
color: _iconColor.value ?? Theme.of(context).colorScheme.outline),
borderRadius: const BorderRadius.all(Radius.circular(kBorderRadius)));
..end = const RoundedRectangleBorder(

// side: BorderSide(
// width: 1,
// color: _iconColor.value ?? Theme.of(context).colorScheme.outline),
borderRadius: BorderRadius.all(Radius.circular(kBorderRadius)));
}

void _updateHeaderColor(ExpansionTileThemeData expansionTileTheme,
Expand Down Expand Up @@ -219,12 +227,12 @@ class _ExpansionEditState extends State<ExpansionEdit>
final bool closed = !_isExpanded && _animationController.isDismissed;
final bool shouldRemoveChildren = closed && !widget.maintainState;

final Widget result = Offstage(
Widget result = Offstage(
offstage: closed,
child: TickerMode(
enabled: !closed,
child: Padding(
padding: expansionTileTheme.childrenPadding ?? EdgeInsets.zero,
padding: EdgeInsets.zero,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: getChildrens(),
Expand Down Expand Up @@ -295,12 +303,36 @@ class _ExpansionEditState extends State<ExpansionEdit>
iconColor: _iconColor.value ?? expansionTileTheme.iconColor,
textColor: _headerColor.value,
child: ListTile(
// leadingAndTrailingTextStyle: ,
onTap: _handleTap,
contentPadding: expansionTileTheme.tilePadding,
leading: widget.leading,
contentPadding: EdgeInsets.zero,
// leading: widget.leading,
title: getTitle(),
subtitle: widget.subtitle,
trailing: widget.trailing ?? _buildTrailingIcon(context),
trailing: widget.isNullable
? ElevatedButton(
// style: ,

// iconAlignment: IconAlignment.end,

// padding: EdgeInsets.zero,
onPressed: () {
_toggleExpansion(expand: false);
_isNullPressed = true;
},
child: Text(
"—",
style: Theme.of(context)
.textTheme
.titleLarge
?.copyWith(
color: Theme.of(context).colorScheme.error),
)
// color: _isExpanded
// ? _iconColor.value
// : Theme.of(context).colorScheme.error,
)
: widget.trailing ?? _buildTrailingIcon(context),
// minTileHeight: widget.minTileHeight,
),
),
Expand All @@ -317,25 +349,29 @@ class _ExpansionEditState extends State<ExpansionEdit>
),
);

final bool isShapeProvided =
//todo check this
// widget.shape != null ||
// expansionTileTheme.shape != null ||
// widget.collapsedShape != null ||
expansionTileTheme.collapsedShape != null;

if (isShapeProvided) {
return Material(
clipBehavior: clipBehavior,
color: backgroundColor,
shape: expansionTileBorder,
child: tile,
);
}
const bool isShapeProvided = false;
//todo check this
// widget.shape != null ||
// expansionTileTheme.shape != null ||
// widget.collapsedShape != null ||
// expansionTileTheme.collapsedShape != null;

//When we foucus this will hightlight color to the card
// if (isShapeProvided) {
// return Material(
// clipBehavior: clipBehavior,
// color: backgroundColor,
// shape: expansionTileBorder,
// child: tile,
// );
// }

return DecoratedBox(
decoration: decoration,
child: tile,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: kDefaultPadding),
child: tile,
),
);
}

Expand All @@ -344,8 +380,13 @@ class _ExpansionEditState extends State<ExpansionEdit>
maxLines: 1,
// controller: text,
name: key,
decoration:
const InputDecoration(border: InputBorder.none, hintText: "HINT"),
decoration: InputDecoration(
border: InputBorder.none,
hintText: "HINT",
icon: Icon(
Icons.access_alarms_outlined,
color: _iconColor.value,
)),
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ class BaseEditWidgetState extends State<BaseEditWidget> {
debugPrint("_BaseEdit buildForm ${_viewAbstract.runtimeType}");

return FormBuilder(

autovalidateMode: AutovalidateMode.onUserInteraction,
key: formKey,
onChanged: () {
Expand Down
3 changes: 3 additions & 0 deletions flutter_views/lib/new_screens/base_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,7 @@ abstract class BasePageState<T extends BasePage> extends State<T>
@override
void didUpdateWidget(covariant T oldWidget) {
if (_tabList == null) {

_initBaseTab();
}
buildDrawer = widget.buildDrawer;
Expand Down Expand Up @@ -939,6 +940,7 @@ abstract class BasePageState<T extends BasePage> extends State<T>
debugPrint("getTabBarWidget !has tabBarList pane ");
return null;
}

return TabBar(
controller: _tabBaseController,
dividerColor: Colors.transparent,
Expand Down Expand Up @@ -1346,6 +1348,7 @@ abstract class BasePageState<T extends BasePage> extends State<T>
leading: Icon(Icons.one_x_mobiledata_outlined),
),
ExpansionEdit(
isNullable: true,
title: Text("dsadassa"),
leading: Icon(Icons.abc),
),
Expand Down
2 changes: 2 additions & 0 deletions flutter_views/lib/new_screens/theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ ButtonStyle getButtonStyleIfIcon(BuildContext context, ColorScheme colorSheme) {
elevation: WidgetStateProperty.all(0),
padding: WidgetStateProperty.all(EdgeInsets.zero),
overlayColor: WidgetStateProperty.all(Colors.transparent),

// surfaceTintColor:
// WidgetStateProperty.all(const Color.fromRGBO(0, 0, 0, 0)),
shape: WidgetStateProperty.all(const CircleBorder()),
Expand All @@ -206,6 +207,7 @@ ButtonStyle getButtonStyleIfIcon(BuildContext context, ColorScheme colorSheme) {
}),

textStyle: WidgetStateProperty.resolveWith((states) {
//todo
// if (states.contains(WidgetState.pressed)) {
// return Theme.of(context).textTheme.bodySmall;
// }
Expand Down

0 comments on commit 1e0bfe8

Please sign in to comment.