Skip to content

Commit

Permalink
fix: using default switch theme color and add inActiveSwitchColor
Browse files Browse the repository at this point in the history
  • Loading branch information
yadaniyil committed Dec 5, 2023
1 parent e93eee8 commit 3cfe93e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
4 changes: 4 additions & 0 deletions lib/src/tiles/platforms/android_settings_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class AndroidSettingsTile extends StatelessWidget {
required this.value,
required this.initialValue,
required this.activeSwitchColor,
required this.inActiveSwitchColor,
required this.enabled,
required this.trailing,
this.titlePadding,
Expand All @@ -31,6 +32,7 @@ class AndroidSettingsTile extends StatelessWidget {
final bool initialValue;
final bool enabled;
final Color? activeSwitchColor;
final Color? inActiveSwitchColor;
final Widget? trailing;
final EdgeInsetsGeometry? titlePadding;
final EdgeInsetsGeometry? leadingPadding;
Expand Down Expand Up @@ -151,6 +153,8 @@ class AndroidSettingsTile extends StatelessWidget {
activeColor: enabled
? activeSwitchColor
: theme.themeData.inactiveTitleColor,
inactiveTrackColor: inActiveSwitchColor?.withOpacity(0.4),
inactiveThumbColor: inActiveSwitchColor,
),
)
else if (trailing != null)
Expand Down
4 changes: 4 additions & 0 deletions lib/src/tiles/platforms/ios_settings_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class IOSSettingsTile extends StatefulWidget {
required this.value,
required this.initialValue,
required this.activeSwitchColor,
required this.inActiveSwitchColor,
required this.enabled,
required this.trailing,
this.titlePadding,
Expand All @@ -33,6 +34,7 @@ class IOSSettingsTile extends StatefulWidget {
final bool? initialValue;
final bool enabled;
final Color? activeSwitchColor;
final Color? inActiveSwitchColor;
final Widget? trailing;
final EdgeInsetsGeometry? titlePadding;
final EdgeInsetsGeometry? leadingPadding;
Expand Down Expand Up @@ -149,9 +151,11 @@ class IOSSettingsTileState extends State<IOSSettingsTile> {
CupertinoSwitch(
value: widget.initialValue ?? true,
onChanged: widget.onToggle,
applyTheme: true,
activeColor: widget.enabled
? widget.activeSwitchColor
: theme.themeData.inactiveTitleColor,
trackColor: widget.inActiveSwitchColor,
),
if (widget.tileType == SettingsTileType.navigationTile &&
widget.value != null)
Expand Down
13 changes: 9 additions & 4 deletions lib/src/tiles/platforms/web_settings_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class WebSettingsTile extends StatelessWidget {
required this.value,
required this.initialValue,
required this.activeSwitchColor,
required this.inActiveSwitchColor,
required this.enabled,
required this.trailing,
this.titlePadding,
Expand All @@ -32,6 +33,7 @@ class WebSettingsTile extends StatelessWidget {
final bool enabled;
final Widget? trailing;
final Color? activeSwitchColor;
final Color? inActiveSwitchColor;
final EdgeInsetsGeometry? titlePadding;
final EdgeInsetsGeometry? leadingPadding;
final EdgeInsetsGeometry? trailingPadding;
Expand Down Expand Up @@ -156,9 +158,11 @@ class WebSettingsTile extends StatelessWidget {
padding: const EdgeInsetsDirectional.only(end: 8),
child: Switch(
activeColor: enabled
? (activeSwitchColor ??
const Color.fromRGBO(138, 180, 248, 1.0))
? activeSwitchColor
: theme.themeData.inactiveTitleColor,
inactiveTrackColor:
inActiveSwitchColor?.withOpacity(0.4),
inactiveThumbColor: inActiveSwitchColor,
value: initialValue,
onChanged: onToggle,
),
Expand All @@ -171,9 +175,10 @@ class WebSettingsTile extends StatelessWidget {
child: Switch(
value: initialValue,
activeColor: enabled
? (activeSwitchColor ??
const Color.fromRGBO(138, 180, 248, 1.0))
? activeSwitchColor
: theme.themeData.inactiveTitleColor,
inactiveTrackColor: inActiveSwitchColor?.withOpacity(0.4),
inactiveThumbColor: inActiveSwitchColor,
onChanged: onToggle,
),
)
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 @@ -28,6 +28,7 @@ class SettingsTile extends AbstractSettingsTile {
onToggle = null;
initialValue = null;
activeSwitchColor = null;
inActiveSwitchColor = null;
tileType = SettingsTileType.simpleTile;
}

Expand All @@ -50,13 +51,15 @@ class SettingsTile extends AbstractSettingsTile {
onToggle = null;
initialValue = null;
activeSwitchColor = null;
inActiveSwitchColor = null;
tileType = SettingsTileType.navigationTile;
}

SettingsTile.switchTile({
required this.initialValue,
required this.onToggle,
this.activeSwitchColor,
this.inActiveSwitchColor,
this.leading,
this.trailing,
required this.title,
Expand Down Expand Up @@ -100,6 +103,7 @@ class SettingsTile extends AbstractSettingsTile {
final EdgeInsetsGeometry? titleDescriptionPadding;

late final Color? activeSwitchColor;
late final Color? inActiveSwitchColor;
late final Widget? value;
late final Function(bool value)? onToggle;
late final SettingsTileType tileType;
Expand All @@ -124,6 +128,7 @@ class SettingsTile extends AbstractSettingsTile {
title: title,
enabled: enabled,
activeSwitchColor: activeSwitchColor,
inActiveSwitchColor: inActiveSwitchColor,
initialValue: initialValue ?? false,
trailing: trailing,
titlePadding: titlePadding,
Expand All @@ -146,6 +151,7 @@ class SettingsTile extends AbstractSettingsTile {
trailing: trailing,
enabled: enabled,
activeSwitchColor: activeSwitchColor,
inActiveSwitchColor: inActiveSwitchColor,
initialValue: initialValue ?? false,
titlePadding: titlePadding,
leadingPadding: leadingPadding,
Expand All @@ -163,6 +169,7 @@ class SettingsTile extends AbstractSettingsTile {
enabled: enabled,
trailing: trailing,
activeSwitchColor: activeSwitchColor,
inActiveSwitchColor: inActiveSwitchColor,
initialValue: initialValue ?? false,
titlePadding: titlePadding,
leadingPadding: leadingPadding,
Expand Down

0 comments on commit 3cfe93e

Please sign in to comment.