From 888c05e526b52bbf5524af511bff6f376802c6d5 Mon Sep 17 00:00:00 2001 From: Sonu Sharma Date: Fri, 17 Jul 2020 12:27:55 +0530 Subject: [PATCH] :wheelchair: Settings checkbox and switch accessibility improved --- .../accountSettings/about/aboutTwitter.dart | 33 +++++++++++- .../accessibility/accessibility.dart | 4 +- .../displaySettings/displayAndSoundPage.dart | 10 ++-- .../notifications/notificationPage.dart | 3 +- .../privacyAndSafetyPage.dart | 3 +- .../accountSettings/proxy/proxyPage.dart | 2 +- .../settings/widgets/settingsRowWidget.dart | 19 +++---- lib/widgets/newWidget/customCheckBox.dart | 51 +++++++++++++++++++ 8 files changed, 99 insertions(+), 26 deletions(-) create mode 100644 lib/widgets/newWidget/customCheckBox.dart diff --git a/lib/page/settings/accountSettings/about/aboutTwitter.dart b/lib/page/settings/accountSettings/about/aboutTwitter.dart index 342390de..ace907c3 100644 --- a/lib/page/settings/accountSettings/about/aboutTwitter.dart +++ b/lib/page/settings/accountSettings/about/aboutTwitter.dart @@ -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"); @@ -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"); + } + ), ], ), ); diff --git a/lib/page/settings/accountSettings/accessibility/accessibility.dart b/lib/page/settings/accountSettings/accessibility/accessibility.dart index e6fb10e1..fb0fb1f2 100644 --- a/lib/page/settings/accountSettings/accessibility/accessibility.dart +++ b/lib/page/settings/accountSettings/accessibility/accessibility.dart @@ -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); }, @@ -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); }, diff --git a/lib/page/settings/accountSettings/displaySettings/displayAndSoundPage.dart b/lib/page/settings/accountSettings/displaySettings/displayAndSoundPage.dart index 99e1ee9d..3658fb83 100644 --- a/lib/page/settings/accountSettings/displaySettings/displayAndSoundPage.dart +++ b/lib/page/settings/accountSettings/displaySettings/displayAndSoundPage.dart @@ -120,7 +120,7 @@ class DisplayAndSoundPage extends StatelessWidget { HeaderWidget('Media'), SettingRowWidget( "Media Previews", - showCheckBox: true, + showCheckBox: false, ), Divider(height: 0), HeaderWidget('Display'), @@ -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', @@ -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, ), ], ), diff --git a/lib/page/settings/accountSettings/notifications/notificationPage.dart b/lib/page/settings/accountSettings/notifications/notificationPage.dart index 79791c8b..6b420b70 100644 --- a/lib/page/settings/accountSettings/notifications/notificationPage.dart +++ b/lib/page/settings/accountSettings/notifications/notificationPage.dart @@ -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 { @@ -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.', ), diff --git a/lib/page/settings/accountSettings/privacyAndSafety/privacyAndSafetyPage.dart b/lib/page/settings/accountSettings/privacyAndSafety/privacyAndSafetyPage.dart index b96a44eb..421d41ba 100644 --- a/lib/page/settings/accountSettings/privacyAndSafety/privacyAndSafetyPage.dart +++ b/lib/page/settings/accountSettings/privacyAndSafety/privacyAndSafetyPage.dart @@ -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 { @@ -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', diff --git a/lib/page/settings/accountSettings/proxy/proxyPage.dart b/lib/page/settings/accountSettings/proxy/proxyPage.dart index 9cf642d1..928fd3fd 100644 --- a/lib/page/settings/accountSettings/proxy/proxyPage.dart +++ b/lib/page/settings/accountSettings/proxy/proxyPage.dart @@ -24,7 +24,7 @@ class ProxyPage extends StatelessWidget { children: [ SettingRowWidget( "Enable HTTP Proxy", - showCheckBox: true, + showCheckBox: false, vPadding: 15, showDivider: true, subtitle: diff --git a/lib/page/settings/widgets/settingsRowWidget.dart b/lib/page/settings/widgets/settingsRowWidget.dart index 022e7e2e..7b17d152 100644 --- a/lib/page/settings/widgets/settingsRowWidget.dart +++ b/lib/page/settings/widgets/settingsRowWidget.dart @@ -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( @@ -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; @@ -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) ], ); } } + diff --git a/lib/widgets/newWidget/customCheckBox.dart b/lib/widgets/newWidget/customCheckBox.dart new file mode 100644 index 00000000..faae9f40 --- /dev/null +++ b/lib/widgets/newWidget/customCheckBox.dart @@ -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 { + ValueNotifier isChecked = ValueNotifier(false); + ValueNotifier 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( + 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, + ); + }, + ); + } +}