Skip to content

Commit

Permalink
♿ Settings checkbox and switch accessibility improved
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAlphamerc committed Jul 17, 2020
1 parent d021e12 commit 888c05e
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 26 deletions.
33 changes: 31 additions & 2 deletions lib/page/settings/accountSettings/about/aboutTwitter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class AboutPage extends StatelessWidget {
),
SettingRowWidget(
"Help Centre",
vPadding: 15,
vPadding: 0,
showDivider: false,
onPressed: (){
launchURL("https://github.com/TheAlphamerc/flutter_twitter_clone/issues");
Expand Down Expand Up @@ -59,7 +59,36 @@ class AboutPage extends StatelessWidget {
useRootNavigator: true,
);
},
)
),
HeaderWidget('Developer'),
SettingRowWidget(
"Github",
showDivider: true,
onPressed: (){
launchURL("https://github.com/TheAlphamerc");
}
),
SettingRowWidget(
"LinkidIn",
showDivider: true,
onPressed: (){
launchURL("https://www.linkedin.com/in/thealphamerc/");
}
),
SettingRowWidget(
"Twitter",
showDivider: true,
onPressed: (){
launchURL("https://twitter.com/TheAlphaMerc");
}
),
SettingRowWidget(
"Blog",
showDivider: true,
onPressed: (){
launchURL("https://dev.to/thealphamerc");
}
),
],
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class AccessibilityPage extends StatelessWidget {
subtitle:
'Adds the ability to describe images for the visually impaired.',
vPadding: 15,
showCheckBox: true,
showCheckBox: false,
onPressed: () {
openDarkModeSettings(context);
},
Expand All @@ -144,7 +144,7 @@ class AccessibilityPage extends StatelessWidget {
subtitle:
'Limit the amount of in-app animations, including live engagement counts.',
vPadding: 15,
showCheckBox: true,
showCheckBox: false,
onPressed: () {
openDarkModeSettings(context);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class DisplayAndSoundPage extends StatelessWidget {
HeaderWidget('Media'),
SettingRowWidget(
"Media Previews",
showCheckBox: true,
showCheckBox: false,
),
Divider(height: 0),
HeaderWidget('Display'),
Expand All @@ -145,7 +145,7 @@ class DisplayAndSoundPage extends StatelessWidget {
subtitle:
'Use the Fwitter set instead of your device\'s default set',
showDivider: false,
showCheckBox: true,
showCheckBox: false,
),
HeaderWidget(
'Sound',
Expand All @@ -154,16 +154,16 @@ class DisplayAndSoundPage extends StatelessWidget {
SettingRowWidget(
"Sound effects",
// vPadding: 15,
showCheckBox: true,
showCheckBox: false,
),
HeaderWidget(
'Web browser',
secondHeader: true,
secondHeader: false,
),
SettingRowWidget(
"Use in-app browser",
subtitle: 'Open external links with Fwitter browser',
showCheckBox: true,
showCheckBox: false,
),
],
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import 'package:flutter_twitter_clone/page/settings/widgets/headerWidget.dart';
import 'package:flutter_twitter_clone/page/settings/widgets/settingsAppbar.dart';
import 'package:flutter_twitter_clone/page/settings/widgets/settingsRowWidget.dart';
import 'package:flutter_twitter_clone/state/authState.dart';
import 'package:flutter_twitter_clone/widgets/newWidget/customUrlText.dart';
import 'package:provider/provider.dart';

class NotificationPage extends StatelessWidget {
Expand Down Expand Up @@ -39,7 +38,7 @@ class NotificationPage extends StatelessWidget {
),
SettingRowWidget(
"Unread notification count badge",
showCheckBox: true,
showCheckBox: false,
subtitle:
'Display a badge with the number of notifications waiting for you inside the Fwitter app.',
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import 'package:flutter_twitter_clone/page/settings/widgets/headerWidget.dart';
import 'package:flutter_twitter_clone/page/settings/widgets/settingsAppbar.dart';
import 'package:flutter_twitter_clone/page/settings/widgets/settingsRowWidget.dart';
import 'package:flutter_twitter_clone/state/authState.dart';
import 'package:flutter_twitter_clone/widgets/newWidget/customUrlText.dart';
import 'package:provider/provider.dart';

class PrivacyAndSaftyPage extends StatelessWidget {
Expand Down Expand Up @@ -107,7 +106,7 @@ class PrivacyAndSaftyPage extends StatelessWidget {
SettingRowWidget(
"Precise location",
subtitle:
'Disabled \n\n\nIf enabled, Fwitter will collect, store, and use your device\'s precise location, such as your GPS information. This lets Fwitter improve your experience - for rxample, showing you mpre local content, ads, and recommendations.',
'Disabled \n\n\nIf enabled, Fwitter will collect, store, and use your device\'s precise location, such as your GPS information. This lets Fwitter improve your experience - for example, showing you mpre local content, ads, and recommendations.',
),
HeaderWidget(
'Personalisation and data',
Expand Down
2 changes: 1 addition & 1 deletion lib/page/settings/accountSettings/proxy/proxyPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ProxyPage extends StatelessWidget {
children: <Widget>[
SettingRowWidget(
"Enable HTTP Proxy",
showCheckBox: true,
showCheckBox: false,
vPadding: 15,
showDivider: true,
subtitle:
Expand Down
19 changes: 7 additions & 12 deletions lib/page/settings/widgets/settingsRowWidget.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'package:flutter/material.dart';
import 'package:flutter_twitter_clone/helper/theme.dart';
import 'package:flutter_twitter_clone/widgets/newWidget/customCheckBox.dart';
import 'package:flutter_twitter_clone/widgets/newWidget/customUrlText.dart';
import 'package:provider/provider.dart';

class SettingRowWidget extends StatelessWidget {
const SettingRowWidget(
Expand All @@ -12,8 +14,8 @@ class SettingRowWidget extends StatelessWidget {
this.onPressed,
this.vPadding = 0,
this.showDivider = true,
this.visibleSwitch = false,
this.showCheckBox = false,
this.visibleSwitch ,
this.showCheckBox ,
}) : super(key: key);
final bool visibleSwitch, showDivider, showCheckBox;
final String navigateTo;
Expand Down Expand Up @@ -52,19 +54,12 @@ class SettingRowWidget extends StatelessWidget {
style: TextStyle(
color: TwitterColor.paleSky, fontWeight: FontWeight.w400),
),
trailing: showCheckBox
? !showCheckBox
? SizedBox()
: Checkbox(value: true, onChanged: (val) {})
: !visibleSwitch
? null
: Switch(
onChanged: (val) {},
value: false,
),
trailing: CustomCheckBox(isChecked:showCheckBox,visibleSwitch: visibleSwitch, )

),
!showDivider ? SizedBox() : Divider(height: 0)
],
);
}
}

51 changes: 51 additions & 0 deletions lib/widgets/newWidget/customCheckBox.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import 'package:flutter/material.dart';

class CustomCheckBox extends StatefulWidget {
final bool isChecked;
final bool visibleSwitch;
CustomCheckBox({Key key, this.isChecked, this.visibleSwitch})
: super(key: key);

@override
_CustomCheckBoxState createState() => _CustomCheckBoxState();
}

class _CustomCheckBoxState extends State<CustomCheckBox> {
ValueNotifier<bool> isChecked = ValueNotifier(false);
ValueNotifier<bool> visibleSwitch = ValueNotifier(false);
@override
void initState() {
isChecked.value = widget.isChecked ;
visibleSwitch.value = widget.visibleSwitch;
super.initState();
}

@override
Widget build(BuildContext context) {
return widget.isChecked != null
? ValueListenableBuilder<bool>(
valueListenable: isChecked,
builder: (context, value, child) {
return Checkbox(
value: value,
onChanged: (val) {
isChecked.value = val;
},
);
},
)
: widget.visibleSwitch == null
? SizedBox(height: 10, width:10,)
: ValueListenableBuilder(
valueListenable: visibleSwitch,
builder: (context, value, child) {
return Switch(
onChanged: (val) {
visibleSwitch.value = val;
},
value: value,
);
},
);
}
}

0 comments on commit 888c05e

Please sign in to comment.