Skip to content
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

Add compact SettingsTile option #178

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
8 changes: 6 additions & 2 deletions lib/src/tiles/platforms/android_settings_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class AndroidSettingsTile extends StatelessWidget {
required this.activeSwitchColor,
required this.enabled,
required this.trailing,
required this.compact,
Key? key,
}) : super(key: key);

Expand All @@ -28,6 +29,7 @@ class AndroidSettingsTile extends StatelessWidget {
final bool enabled;
final Color? activeSwitchColor;
final Widget? trailing;
final bool compact;

@override
Widget build(BuildContext context) {
Expand All @@ -38,6 +40,8 @@ class AndroidSettingsTile extends StatelessWidget {
? onToggle == null && onPressed == null
: onPressed == null;

final double tilePadding = this.compact ? 10 : 19;

return IgnorePointer(
ignoring: !enabled,
child: Material(
Expand Down Expand Up @@ -73,8 +77,8 @@ class AndroidSettingsTile extends StatelessWidget {
padding: EdgeInsetsDirectional.only(
start: 24,
end: 24,
bottom: 19 * scaleFactor,
top: 19 * scaleFactor,
bottom: tilePadding * scaleFactor,
top: tilePadding * scaleFactor,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
Expand Down
8 changes: 6 additions & 2 deletions lib/src/tiles/platforms/ios_settings_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class IOSSettingsTile extends StatefulWidget {
required this.activeSwitchColor,
required this.enabled,
required this.trailing,
required this.compact,
Key? key,
}) : super(key: key);

Expand All @@ -29,6 +30,7 @@ class IOSSettingsTile extends StatefulWidget {
final bool enabled;
final Color? activeSwitchColor;
final Widget? trailing;
final bool compact;

@override
_IOSSettingsTileState createState() => _IOSSettingsTileState();
Expand Down Expand Up @@ -176,6 +178,8 @@ class _IOSSettingsTileState extends State<IOSSettingsTile> {
) {
final scaleFactor = MediaQuery.of(context).textScaleFactor;

final double tilePadding = widget.compact ? 7 : 12.5;

return GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: widget.onPressed == null
Expand Down Expand Up @@ -227,8 +231,8 @@ class _IOSSettingsTileState extends State<IOSSettingsTile> {
Expanded(
child: Padding(
padding: EdgeInsetsDirectional.only(
top: 12.5 * scaleFactor,
bottom: 12.5 * scaleFactor,
top: tilePadding * scaleFactor,
bottom: tilePadding * scaleFactor,
),
child: DefaultTextStyle(
style: TextStyle(
Expand Down
8 changes: 6 additions & 2 deletions lib/src/tiles/platforms/web_settings_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class WebSettingsTile extends StatelessWidget {
required this.activeSwitchColor,
required this.enabled,
required this.trailing,
required this.compact,
Key? key,
}) : super(key: key);

Expand All @@ -29,12 +30,15 @@ class WebSettingsTile extends StatelessWidget {
final bool enabled;
final Widget? trailing;
final Color? activeSwitchColor;
final bool compact;

@override
Widget build(BuildContext context) {
final theme = SettingsTheme.of(context);
final scaleFactor = MediaQuery.of(context).textScaleFactor;

final double tilePadding = this.compact ? 10 : 19;

final cantShowAnimation = tileType == SettingsTileType.switchTile
? onToggle == null && onPressed == null
: onPressed == null;
Expand Down Expand Up @@ -74,8 +78,8 @@ class WebSettingsTile extends StatelessWidget {
padding: EdgeInsetsDirectional.only(
start: 24,
end: 24,
bottom: 19 * scaleFactor,
top: 19 * scaleFactor,
bottom: tilePadding * scaleFactor,
top: tilePadding * scaleFactor,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
Expand Down
7 changes: 7 additions & 0 deletions lib/src/tiles/settings_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class SettingsTile extends AbstractSettingsTile {
this.description,
this.onPressed,
this.enabled = true,
this.compact = false,
Key? key,
}) : super(key: key) {
onToggle = null;
Expand All @@ -33,6 +34,7 @@ class SettingsTile extends AbstractSettingsTile {
this.description,
this.onPressed,
this.enabled = true,
this.compact = false,
Key? key,
}) : super(key: key) {
onToggle = null;
Expand All @@ -51,6 +53,7 @@ class SettingsTile extends AbstractSettingsTile {
this.description,
this.onPressed,
this.enabled = true,
this.compact = false,
Key? key,
}) : super(key: key) {
value = null;
Expand Down Expand Up @@ -78,6 +81,7 @@ class SettingsTile extends AbstractSettingsTile {
late final SettingsTileType tileType;
late final bool? initialValue;
late final bool enabled;
late final bool compact;

@override
Widget build(BuildContext context) {
Expand All @@ -96,6 +100,7 @@ class SettingsTile extends AbstractSettingsTile {
leading: leading,
title: title,
enabled: enabled,
compact: compact,
activeSwitchColor: activeSwitchColor,
initialValue: initialValue ?? false,
trailing: trailing,
Expand All @@ -113,6 +118,7 @@ class SettingsTile extends AbstractSettingsTile {
title: title,
trailing: trailing,
enabled: enabled,
compact: compact,
activeSwitchColor: activeSwitchColor,
initialValue: initialValue ?? false,
);
Expand All @@ -127,6 +133,7 @@ class SettingsTile extends AbstractSettingsTile {
title: title,
enabled: enabled,
trailing: trailing,
compact: compact,
activeSwitchColor: activeSwitchColor,
initialValue: initialValue ?? false,
);
Expand Down