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,6 +321,16 @@ 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: InkWell(
splashFactory: NoSplash.splashFactory,
highlightColor: Colors.transparent,
enableFeedback: false,
onTap: () {
HapticFeedback.selectionClick();
setState(() {
tipId = Random().nextInt(5);
});
},
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: [
@ -336,7 +349,8 @@ class _MainAppState extends State<MainApp> {
color: Colors.grey)), color: Colors.grey)),
), ),
const SizedBox(width: 16), const SizedBox(width: 16),
])))); ])),
)));
}), }),
]) ])
..addAll((prefs?.getStringList("chats") ?? []).map((item) { ..addAll((prefs?.getStringList("chats") ?? []).map((item) {