Set tips to not update every build call

This commit is contained in:
JHubi1 2024-06-03 16:03:33 +02:00
parent 545525ab55
commit 5a98f3eb7a
No known key found for this signature in database
GPG Key ID: 7BF82570CBBBD050
1 changed files with 34 additions and 20 deletions

View File

@ -170,6 +170,8 @@ class _MainAppState extends State<MainApp> {
bool logoVisible = true; bool logoVisible = true;
bool menuVisible = false; bool menuVisible = false;
int tipId = Random().nextInt(5);
List<Widget> sidebar(BuildContext context, Function setState) { List<Widget> sidebar(BuildContext context, Function setState) {
return List.from([ return List.from([
((Platform.isWindows || Platform.isLinux || Platform.isMacOS) && ((Platform.isWindows || Platform.isLinux || Platform.isMacOS) &&
@ -282,7 +284,9 @@ class _MainAppState extends State<MainApp> {
child: InkWell( child: InkWell(
customBorder: const RoundedRectangleBorder( customBorder: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(50))), borderRadius: BorderRadius.all(Radius.circular(50))),
onTap: () {}, onTap: () {
HapticFeedback.selectionClick();
},
child: Padding( child: Padding(
padding: const EdgeInsets.only(top: 16, bottom: 16), padding: const EdgeInsets.only(top: 16, bottom: 16),
child: Row(children: [ child: Row(children: [
@ -302,7 +306,6 @@ class _MainAppState extends State<MainApp> {
const SizedBox(width: 16), const SizedBox(width: 16),
]))))), ]))))),
Builder(builder: (context) { Builder(builder: (context) {
int tipId = Random().nextInt(5);
String tip = (tipId == 0) String tip = (tipId == 0)
? AppLocalizations.of(context)!.tip0 ? AppLocalizations.of(context)!.tip0
: (tipId == 1) : (tipId == 1)
@ -318,25 +321,36 @@ class _MainAppState extends State<MainApp> {
? const SizedBox.shrink() ? const SizedBox.shrink()
: (Padding( : (Padding(
padding: const EdgeInsets.only(left: 12, right: 12), padding: const EdgeInsets.only(left: 12, right: 12),
child: Padding( child: InkWell(
padding: const EdgeInsets.only(top: 16, bottom: 16), splashFactory: NoSplash.splashFactory,
child: Row(children: [ highlightColor: Colors.transparent,
const Padding( enableFeedback: false,
padding: EdgeInsets.only(left: 16, right: 12), onTap: () {
child: Icon(Icons.tips_and_updates_rounded, HapticFeedback.selectionClick();
color: Colors.grey)), setState(() {
Expanded( tipId = Random().nextInt(5);
child: Text( });
AppLocalizations.of(context)!.tipPrefix + tip, },
softWrap: true, child: Padding(
maxLines: 3, padding: const EdgeInsets.only(top: 16, bottom: 16),
overflow: TextOverflow.fade, child: Row(children: [
style: const TextStyle( const Padding(
fontWeight: FontWeight.w500, padding: EdgeInsets.only(left: 16, right: 12),
child: Icon(Icons.tips_and_updates_rounded,
color: Colors.grey)), color: Colors.grey)),
), Expanded(
const SizedBox(width: 16), 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) { ..addAll((prefs?.getStringList("chats") ?? []).map((item) {