From 5a98f3eb7a7475a76a958d91fdf7812542d3b056 Mon Sep 17 00:00:00 2001 From: JHubi1 Date: Mon, 3 Jun 2024 16:03:33 +0200 Subject: [PATCH] Set tips to not update every build call --- lib/main.dart | 54 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 1dd1f8f..0eff5c6 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -170,6 +170,8 @@ class _MainAppState extends State { bool logoVisible = true; bool menuVisible = false; + int tipId = Random().nextInt(5); + List sidebar(BuildContext context, Function setState) { return List.from([ ((Platform.isWindows || Platform.isLinux || Platform.isMacOS) && @@ -282,7 +284,9 @@ class _MainAppState extends State { child: InkWell( customBorder: const RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(50))), - onTap: () {}, + onTap: () { + HapticFeedback.selectionClick(); + }, child: Padding( padding: const EdgeInsets.only(top: 16, bottom: 16), child: Row(children: [ @@ -302,7 +306,6 @@ class _MainAppState extends State { const SizedBox(width: 16), ]))))), Builder(builder: (context) { - int tipId = Random().nextInt(5); String tip = (tipId == 0) ? AppLocalizations.of(context)!.tip0 : (tipId == 1) @@ -318,25 +321,36 @@ class _MainAppState extends State { ? const SizedBox.shrink() : (Padding( padding: const EdgeInsets.only(left: 12, right: 12), - child: Padding( - padding: const EdgeInsets.only(top: 16, bottom: 16), - child: Row(children: [ - const Padding( - padding: EdgeInsets.only(left: 16, right: 12), - child: Icon(Icons.tips_and_updates_rounded, - color: Colors.grey)), - Expanded( - child: Text( - AppLocalizations.of(context)!.tipPrefix + tip, - softWrap: true, - maxLines: 3, - overflow: TextOverflow.fade, - style: const TextStyle( - fontWeight: FontWeight.w500, + child: InkWell( + splashFactory: NoSplash.splashFactory, + highlightColor: Colors.transparent, + enableFeedback: false, + onTap: () { + HapticFeedback.selectionClick(); + setState(() { + tipId = Random().nextInt(5); + }); + }, + child: Padding( + padding: const EdgeInsets.only(top: 16, bottom: 16), + child: Row(children: [ + const Padding( + padding: EdgeInsets.only(left: 16, right: 12), + child: Icon(Icons.tips_and_updates_rounded, color: Colors.grey)), - ), - const SizedBox(width: 16), - ])))); + Expanded( + child: Text( + AppLocalizations.of(context)!.tipPrefix + tip, + softWrap: true, + maxLines: 3, + overflow: TextOverflow.fade, + style: const TextStyle( + fontWeight: FontWeight.w500, + color: Colors.grey)), + ), + const SizedBox(width: 16), + ])), + ))); }), ]) ..addAll((prefs?.getStringList("chats") ?? []).map((item) {