Skip to content

Commit

Permalink
Fixed 'trailing' when used 'SettingsTile.switchTile'.
Browse files Browse the repository at this point in the history
Fixed color scheme on web version.
Update WebChromeSettings  in example.
  • Loading branch information
M-ixai-L committed Jun 8, 2022
1 parent 3db24c9 commit a2565cb
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 31 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
## [2.0.3] - [June 2, 2022]
## [2.0.3] - [June 8, 2022]
* Updated documentation
* Fixed display of web support on pub.dev
* Fixed scrollbar on wide screens
* Fixed 'trailing' when used 'SettingsTile.switchTile'
* Fixed color scheme on web version

## [2.0.2] - [January 24, 2022]
* Enabled parameter for the ListTile widget
* Trailing parameter for the ListTile widget
* Trailing parameter for the ListTile widget
* Fixed minor bugs

## [2.0.1] - [January 9, 2022]
Expand Down
53 changes: 53 additions & 0 deletions example/lib/screens/gallery/web_chrome_addresses_settings.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import 'package:flutter/material.dart';
import 'package:settings_ui/settings_ui.dart';

class WebChromeAddressesScreen extends StatefulWidget {
WebChromeAddressesScreen({Key key}) : super(key: key);

@override
State<WebChromeAddressesScreen> createState() =>
_WebChromeAddressesScreenState();
}

class _WebChromeAddressesScreenState extends State<WebChromeAddressesScreen> {
bool _toggle = true;

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Addresses and more')),
body: SettingsList(
platform: DevicePlatform.web,
sections: [
SettingsSection(
margin: EdgeInsetsDirectional.only(top: 40),
tiles: [
SettingsTile.switchTile(
initialValue: _toggle,
onToggle: (_) {
setState(() {
_toggle = _;
});
},
trailing: Icon(Icons.info),
title: Text('Save and fill addresses'),
description: Text(
'Include information like phone numbers, email, and shipping addresses'),
),
],
),
SettingsSection(
title: Text('Addresses'),
tiles: [
SettingsTile.navigation(
onPressed: (_) {},
title: Text('Name, addresses'),
trailing: Icon(Icons.more_vert),
),
],
),
],
),
);
}
}
10 changes: 9 additions & 1 deletion example/lib/screens/gallery/web_chrome_settings.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'package:example/screens/gallery/web_chrome_addresses_settings.dart';
import 'package:example/utils/navigation.dart';
import 'package:flutter/material.dart';
import 'package:settings_ui/settings_ui.dart';

Expand Down Expand Up @@ -25,7 +27,13 @@ class WebChromeSettings extends StatelessWidget {
title: Text('Payment methods'),
),
SettingsTile.navigation(
onPressed: (_) {},
onPressed: (_) {
Navigation.navigateTo(
context: context,
screen: WebChromeAddressesScreen(),
style: NavigationRouteStyle.material,
);
},
leading: Icon(Icons.location_on),
title: Text('Addresses and more'),
),
Expand Down
2 changes: 0 additions & 2 deletions example/lib/screens/gallery_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,8 @@ class GalleryScreen extends StatelessWidget {
},
),
SettingsTile.navigation(
enabled: false,
leading: Icon(Icons.web),
title: Text('Web Settings'),
description: Text('In development'),
onPressed: (context) {
Navigation.navigateTo(
context: context,
Expand Down
31 changes: 21 additions & 10 deletions lib/src/tiles/platforms/android_settings_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,21 @@ class AndroidSettingsTile extends StatelessWidget {
),
),
),
// if (tileType == SettingsTileType.switchTile)
// SizedBox(
// height: 30,
// child: VerticalDivider(),
// ),
if (trailing != null)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: trailing!,
if (trailing != null && tileType == SettingsTileType.switchTile)
Row(
children: [
trailing!,
Padding(
padding: const EdgeInsetsDirectional.only(end: 8),
child: Switch(
value: initialValue,
onChanged: onToggle,
activeColor: enabled
? activeSwitchColor
: theme.themeData.inactiveTitleColor,
),
),
],
)
else if (tileType == SettingsTileType.switchTile)
Padding(
Expand All @@ -138,7 +144,12 @@ class AndroidSettingsTile extends StatelessWidget {
? activeSwitchColor
: theme.themeData.inactiveTitleColor,
),
),
)
else if (trailing != null)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: trailing!,
)
],
),
),
Expand Down
10 changes: 1 addition & 9 deletions lib/src/tiles/platforms/ios_settings_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -121,19 +121,11 @@ class _IOSSettingsTileState extends State<IOSSettingsTile> {
required BuildContext context,
required SettingsTheme theme,
}) {
if (widget.trailing != null) return widget.trailing!;

if (widget.tileType == SettingsTileType.simpleTile) {
if (widget.value == null) {
return Container();
}
return widget.value!;
}

final scaleFactor = MediaQuery.of(context).textScaleFactor;

return Row(
children: [
if (widget.trailing != null) widget.trailing!,
if (widget.tileType == SettingsTileType.switchTile)
CupertinoSwitch(
value: widget.initialValue ?? true,
Expand Down
31 changes: 24 additions & 7 deletions lib/src/tiles/platforms/web_settings_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,19 +111,36 @@ class WebSettingsTile extends StatelessWidget {
),
),
),
// if (tileType == SettingsTileType.switchTile)
// SizedBox(
// height: 30,
// child: VerticalDivider(),
// ),
if (tileType == SettingsTileType.switchTile)
if (trailing != null && tileType == SettingsTileType.switchTile)
Row(
children: [
trailing!,
Padding(
padding: const EdgeInsetsDirectional.only(end: 8),
child: Switch(
activeColor: activeSwitchColor ??
Color.fromRGBO(138, 180, 248, 1.0),
value: initialValue,
onChanged: onToggle,
),
),
],
)
else if (tileType == SettingsTileType.switchTile)
Padding(
padding:
const EdgeInsetsDirectional.only(start: 16, end: 8),
child: Switch.adaptive(
child: Switch(
value: initialValue,
activeColor: activeSwitchColor ??
Color.fromRGBO(138, 180, 248, 1.0),
onChanged: onToggle,
),
)
else if (trailing != null)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: trailing!,
),
],
),
Expand Down

0 comments on commit a2565cb

Please sign in to comment.