From 4914df561029036e34664a7979515f84882f9020 Mon Sep 17 00:00:00 2001 From: otsmr Date: Mon, 27 Oct 2025 23:55:02 +0100 Subject: [PATCH] linter issues --- lib/src/views/chats/archived_chats.view.dart | 2 +- lib/src/views/chats/chat_list.view.dart | 390 +++++++++--------- .../chat_list_components/group_list_item.dart | 1 - .../components/context_menu.component.dart | 2 +- 4 files changed, 195 insertions(+), 200 deletions(-) diff --git a/lib/src/views/chats/archived_chats.view.dart b/lib/src/views/chats/archived_chats.view.dart index e769afa..a785c0b 100644 --- a/lib/src/views/chats/archived_chats.view.dart +++ b/lib/src/views/chats/archived_chats.view.dart @@ -40,7 +40,7 @@ class _ArchivedChatsViewState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text("Archivierte Chats"), + title: const Text('Archivierte Chats'), ), body: ListView( children: _groupsArchived.map((group) { diff --git a/lib/src/views/chats/chat_list.view.dart b/lib/src/views/chats/chat_list.view.dart index 2bbf609..ca1acca 100644 --- a/lib/src/views/chats/chat_list.view.dart +++ b/lib/src/views/chats/chat_list.view.dart @@ -105,219 +105,215 @@ class _ChatListViewState extends State { Widget build(BuildContext context) { final isConnected = context.watch().isConnected; final planId = context.watch().plan; - return Container( - child: Scaffold( - appBar: AppBar( - title: Row( - children: [ - GestureDetector( - onTap: () async { - await Navigator.push( - context, - MaterialPageRoute( - builder: (context) { - return const ProfileView(); - }, - ), - ); - if (!mounted) return; - setState(() {}); // gUser has updated - }, - child: AvatarIcon( - userData: gUser, - fontSize: 14, - color: context.color.onSurface.withAlpha(20), - ), - ), - const SizedBox(width: 10), - const Text('twonly '), - if (planId != 'Free') - GestureDetector( - onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) { - return const SubscriptionView(); - }, - ), - ); - }, - child: Container( - decoration: BoxDecoration( - color: context.color.primary, - borderRadius: BorderRadius.circular(15), - ), - padding: - const EdgeInsets.symmetric(horizontal: 5, vertical: 3), - child: Text( - planId, - style: TextStyle( - fontSize: 10, - fontWeight: FontWeight.bold, - color: - isDarkMode(context) ? Colors.black : Colors.white, - ), - ), - ), - ), - ], - ), - actions: [ - const FeedbackIconButton(), - StreamBuilder( - stream: twonlyDB.contactsDao.watchContactsRequested(), - builder: (context, snapshot) { - var count = 0; - if (snapshot.hasData && snapshot.data != null) { - count = snapshot.data!; - } - return NotificationBadge( - count: count.toString(), - child: IconButton( - key: searchForOtherUsers, - icon: const FaIcon(FontAwesomeIcons.userPlus, size: 18), - onPressed: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => const AddNewUserView(), - ), - ); - }, - ), - ); - }, - ), - IconButton( - onPressed: () async { + return Scaffold( + appBar: AppBar( + title: Row( + children: [ + GestureDetector( + onTap: () async { await Navigator.push( context, MaterialPageRoute( - builder: (context) => const SettingsMainView(), + builder: (context) { + return const ProfileView(); + }, ), ); if (!mounted) return; - setState(() {}); // gUser may has changed... + setState(() {}); // gUser has updated }, - icon: const FaIcon(FontAwesomeIcons.gear, size: 19), - ), - ], - ), - body: Stack( - children: [ - Positioned( - top: 0, - left: 0, - right: 0, - child: isConnected ? Container() : const ConnectionInfo(), - ), - Positioned.fill( - child: Container( - child: RefreshIndicator( - onRefresh: () async { - await apiService.close(() {}); - await apiService.connect(force: true); - await Future.delayed(const Duration(seconds: 1)); - }, - child: (_groupsNotPinned.isEmpty && - _groupsPinned.isEmpty && - _groupsArchived.isEmpty) - ? Center( - child: Padding( - padding: const EdgeInsets.all(10), - child: OutlinedButton.icon( - icon: const Icon(Icons.person_add), - onPressed: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => - const AddNewUserView(), - ), - ); - }, - label: Text( - context.lang.chatListViewSearchUserNameBtn), - ), - ), - ) - : ListView.builder( - itemCount: _groupsPinned.length + - (_groupsPinned.isNotEmpty ? 1 : 0) + - _groupsNotPinned.length + - (_groupsArchived.isNotEmpty ? 1 : 0), - itemBuilder: (context, index) { - if (index >= - _groupsNotPinned.length + - _groupsPinned.length + - (_groupsPinned.isNotEmpty ? 1 : 0)) { - if (_groupsArchived.isEmpty) return Container(); - return ListTile( - title: Text( - "Archivierte Chats (${_groupsArchived.length})", - textAlign: TextAlign.center, - style: TextStyle(fontSize: 13), - ), - onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) { - return ArchivedChatsView(); - }, - ), - ); - }, - ); - } - // Check if the index is for the pinned users - if (index < _groupsPinned.length) { - final group = _groupsPinned[index]; - return GroupListItem( - key: ValueKey(group.groupId), - group: group, - ); - } - - // If there are pinned users, account for the Divider - var adjustedIndex = index - _groupsPinned.length; - if (_groupsPinned.isNotEmpty && - adjustedIndex == 0) { - return const Divider(); - } - - // Adjust the index for the contacts list - adjustedIndex -= (_groupsPinned.isNotEmpty ? 1 : 0); - - // Get the contacts that are not pinned - final group = _groupsNotPinned.elementAt( - adjustedIndex, - ); - return GroupListItem( - key: ValueKey(group.groupId), group: group); - }, - ), - ), + child: AvatarIcon( + userData: gUser, + fontSize: 14, + color: context.color.onSurface.withAlpha(20), ), ), + const SizedBox(width: 10), + const Text('twonly '), + if (planId != 'Free') + GestureDetector( + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) { + return const SubscriptionView(); + }, + ), + ); + }, + child: Container( + decoration: BoxDecoration( + color: context.color.primary, + borderRadius: BorderRadius.circular(15), + ), + padding: + const EdgeInsets.symmetric(horizontal: 5, vertical: 3), + child: Text( + planId, + style: TextStyle( + fontSize: 10, + fontWeight: FontWeight.bold, + color: isDarkMode(context) ? Colors.black : Colors.white, + ), + ), + ), + ), ], ), - floatingActionButton: Padding( - padding: const EdgeInsets.only(bottom: 30), - child: FloatingActionButton( - onPressed: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) { - return const StartNewChatView(); + actions: [ + const FeedbackIconButton(), + StreamBuilder( + stream: twonlyDB.contactsDao.watchContactsRequested(), + builder: (context, snapshot) { + var count = 0; + if (snapshot.hasData && snapshot.data != null) { + count = snapshot.data!; + } + return NotificationBadge( + count: count.toString(), + child: IconButton( + key: searchForOtherUsers, + icon: const FaIcon(FontAwesomeIcons.userPlus, size: 18), + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => const AddNewUserView(), + ), + ); }, ), ); }, - child: const FaIcon(FontAwesomeIcons.penToSquare), ), + IconButton( + onPressed: () async { + await Navigator.push( + context, + MaterialPageRoute( + builder: (context) => const SettingsMainView(), + ), + ); + if (!mounted) return; + setState(() {}); // gUser may has changed... + }, + icon: const FaIcon(FontAwesomeIcons.gear, size: 19), + ), + ], + ), + body: Stack( + children: [ + Positioned( + top: 0, + left: 0, + right: 0, + child: isConnected ? Container() : const ConnectionInfo(), + ), + Positioned.fill( + child: RefreshIndicator( + onRefresh: () async { + await apiService.close(() {}); + await apiService.connect(force: true); + await Future.delayed(const Duration(seconds: 1)); + }, + child: (_groupsNotPinned.isEmpty && + _groupsPinned.isEmpty && + _groupsArchived.isEmpty) + ? Center( + child: Padding( + padding: const EdgeInsets.all(10), + child: OutlinedButton.icon( + icon: const Icon(Icons.person_add), + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => const AddNewUserView(), + ), + ); + }, + label: Text( + context.lang.chatListViewSearchUserNameBtn, + ), + ), + ), + ) + : ListView.builder( + itemCount: _groupsPinned.length + + (_groupsPinned.isNotEmpty ? 1 : 0) + + _groupsNotPinned.length + + (_groupsArchived.isNotEmpty ? 1 : 0), + itemBuilder: (context, index) { + if (index >= + _groupsNotPinned.length + + _groupsPinned.length + + (_groupsPinned.isNotEmpty ? 1 : 0)) { + if (_groupsArchived.isEmpty) return Container(); + return ListTile( + title: Text( + 'Archivierte Chats (${_groupsArchived.length})', + textAlign: TextAlign.center, + style: const TextStyle(fontSize: 13), + ), + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) { + return const ArchivedChatsView(); + }, + ), + ); + }, + ); + } + // Check if the index is for the pinned users + if (index < _groupsPinned.length) { + final group = _groupsPinned[index]; + return GroupListItem( + key: ValueKey(group.groupId), + group: group, + ); + } + + // If there are pinned users, account for the Divider + var adjustedIndex = index - _groupsPinned.length; + if (_groupsPinned.isNotEmpty && adjustedIndex == 0) { + return const Divider(); + } + + // Adjust the index for the contacts list + adjustedIndex -= (_groupsPinned.isNotEmpty ? 1 : 0); + + // Get the contacts that are not pinned + final group = _groupsNotPinned.elementAt( + adjustedIndex, + ); + return GroupListItem( + key: ValueKey(group.groupId), + group: group, + ); + }, + ), + ), + ), + ], + ), + floatingActionButton: Padding( + padding: const EdgeInsets.only(bottom: 30), + child: FloatingActionButton( + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) { + return const StartNewChatView(); + }, + ), + ); + }, + child: const FaIcon(FontAwesomeIcons.penToSquare), ), ), ); diff --git a/lib/src/views/chats/chat_list_components/group_list_item.dart b/lib/src/views/chats/chat_list_components/group_list_item.dart index 417cf8d..597f622 100644 --- a/lib/src/views/chats/chat_list_components/group_list_item.dart +++ b/lib/src/views/chats/chat_list_components/group_list_item.dart @@ -1,5 +1,4 @@ import 'dart:async'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:mutex/mutex.dart'; diff --git a/lib/src/views/components/context_menu.component.dart b/lib/src/views/components/context_menu.component.dart index 0cba731..c2bd12e 100644 --- a/lib/src/views/components/context_menu.component.dart +++ b/lib/src/views/components/context_menu.component.dart @@ -66,7 +66,7 @@ class _ContextMenuState extends State { leading: _getIcon(item.icon), ), ), - ) + ), ], position: RelativeRect.fromRect( _tapPosition! & const Size(40, 40),