-
Notifications
You must be signed in to change notification settings - Fork 377
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* initial commit * leading, title, subtitle, trailing, on_click * additional_info property * bgcolor and bgcolor_activated properties * leading_size and leading_to_title properties * padding property * padding property * clean up * bgcolor to ListTile * adaptive property for ListTile * notched property for CupertinoListTile * toggle_inputs property for CupertinoListTile * clean up * FletControlStatelessMixin * List Tile to use withPagePlatform() --------- Co-authored-by: Feodor Fitsner <feodor@appveyor.com>
- Loading branch information
1 parent
1af2e72
commit e07a272
Showing
6 changed files
with
563 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
import 'package:flutter/cupertino.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
import '../models/control.dart'; | ||
import '../utils/colors.dart'; | ||
import '../utils/edge_insets.dart'; | ||
import '../utils/launch_url.dart'; | ||
import 'create_control.dart'; | ||
import 'flet_control_stateless_mixin.dart'; | ||
import 'list_tile.dart'; | ||
|
||
class CupertinoListTileControl extends StatelessWidget | ||
with FletControlStatelessMixin { | ||
final Control? parent; | ||
final Control control; | ||
final List<Control> children; | ||
final bool parentDisabled; | ||
final ListTileClickNotifier _clickNotifier = ListTileClickNotifier(); | ||
|
||
CupertinoListTileControl( | ||
{super.key, | ||
this.parent, | ||
required this.control, | ||
required this.children, | ||
required this.parentDisabled}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
debugPrint("CupertinoListTile build: ${control.id}"); | ||
|
||
var leadingCtrls = | ||
children.where((c) => c.name == "leading" && c.isVisible); | ||
var titleCtrls = children.where((c) => c.name == "title" && c.isVisible); | ||
var subtitleCtrls = | ||
children.where((c) => c.name == "subtitle" && c.isVisible); | ||
var trailingCtrls = | ||
children.where((c) => c.name == "trailing" && c.isVisible); | ||
var additionalInfoCtrls = | ||
children.where((c) => c.name == "additionalInfo" && c.isVisible); | ||
|
||
bool notched = control.attrBool("notched", false)!; | ||
bool onclick = control.attrBool("onclick", false)!; | ||
bool toggleInputs = control.attrBool("toggleInputs", false)!; | ||
String url = control.attrString("url", "")!; | ||
String? urlTarget = control.attrString("urlTarget"); | ||
bool disabled = control.isDisabled || parentDisabled; | ||
|
||
Widget? additionalInfo = additionalInfoCtrls.isNotEmpty | ||
? createControl(control, additionalInfoCtrls.first.id, disabled) | ||
: null; | ||
Widget? leading = leadingCtrls.isNotEmpty | ||
? createControl(control, leadingCtrls.first.id, disabled) | ||
: null; | ||
|
||
Widget? title = titleCtrls.isNotEmpty | ||
? createControl(control, titleCtrls.first.id, disabled) | ||
: const Text(""); | ||
|
||
Widget? subtitle = subtitleCtrls.isNotEmpty | ||
? createControl(control, subtitleCtrls.first.id, disabled) | ||
: null; | ||
|
||
Widget? trailing = trailingCtrls.isNotEmpty | ||
? createControl(control, trailingCtrls.first.id, disabled) | ||
: null; | ||
|
||
Color? backgroundColor = HexColor.fromString( | ||
Theme.of(context), control.attrString("bgcolor", "")!); | ||
Color? bgcolorActivated = HexColor.fromString( | ||
Theme.of(context), control.attrString("bgcolorActivated", "")!); | ||
|
||
var padding = parseEdgeInsets(control, "contentPadding"); | ||
|
||
Function()? onPressed = (onclick || toggleInputs || url != "") && !disabled | ||
? () { | ||
debugPrint("CupertinoListTile ${control.id} clicked!"); | ||
if (toggleInputs) { | ||
_clickNotifier.onClick(); | ||
} | ||
if (url != "") { | ||
openWebBrowser(url, webWindowName: urlTarget); | ||
} | ||
if (onclick) { | ||
sendControlEvent(context, control.id, "click", ""); | ||
} | ||
} | ||
: null; | ||
|
||
Widget tile; | ||
!notched | ||
? tile = CupertinoListTile( | ||
onTap: onPressed, | ||
additionalInfo: additionalInfo, | ||
backgroundColor: backgroundColor, | ||
backgroundColorActivated: bgcolorActivated, | ||
leading: leading, | ||
leadingSize: control.attrDouble("leadingSize", 28.0)!, | ||
leadingToTitle: control.attrDouble("leadingToTitle", 16.0)!, | ||
padding: padding, | ||
title: title, | ||
subtitle: subtitle, | ||
trailing: trailing, | ||
) | ||
: tile = CupertinoListTile.notched( | ||
onTap: onPressed, | ||
additionalInfo: additionalInfo, | ||
backgroundColor: backgroundColor, | ||
backgroundColorActivated: bgcolorActivated, | ||
leading: leading, | ||
padding: padding, | ||
title: title, | ||
subtitle: subtitle, | ||
trailing: trailing, | ||
); | ||
|
||
if (toggleInputs) { | ||
tile = ListTileClicks(notifier: _clickNotifier, child: tile); | ||
} | ||
|
||
return constrainedControl(context, tile, parent, control); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.