linter issues

This commit is contained in:
otsmr 2025-10-27 23:55:02 +01:00
parent 9d563793c7
commit 4914df5610
4 changed files with 195 additions and 200 deletions

View file

@ -40,7 +40,7 @@ class _ArchivedChatsViewState extends State<ArchivedChatsView> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text("Archivierte Chats"), title: const Text('Archivierte Chats'),
), ),
body: ListView( body: ListView(
children: _groupsArchived.map((group) { children: _groupsArchived.map((group) {

View file

@ -105,219 +105,215 @@ class _ChatListViewState extends State<ChatListView> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final isConnected = context.watch<CustomChangeProvider>().isConnected; final isConnected = context.watch<CustomChangeProvider>().isConnected;
final planId = context.watch<CustomChangeProvider>().plan; final planId = context.watch<CustomChangeProvider>().plan;
return Container( return Scaffold(
child: Scaffold( appBar: AppBar(
appBar: AppBar( title: Row(
title: Row( children: [
children: [ GestureDetector(
GestureDetector( onTap: () async {
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 {
await Navigator.push( await Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (context) => const SettingsMainView(), builder: (context) {
return const ProfileView();
},
), ),
); );
if (!mounted) return; if (!mounted) return;
setState(() {}); // gUser may has changed... setState(() {}); // gUser has updated
}, },
icon: const FaIcon(FontAwesomeIcons.gear, size: 19), child: AvatarIcon(
), userData: gUser,
], fontSize: 14,
), color: context.color.onSurface.withAlpha(20),
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);
},
),
),
), ),
), ),
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( actions: [
padding: const EdgeInsets.only(bottom: 30), const FeedbackIconButton(),
child: FloatingActionButton( StreamBuilder(
onPressed: () { stream: twonlyDB.contactsDao.watchContactsRequested(),
Navigator.push( builder: (context, snapshot) {
context, var count = 0;
MaterialPageRoute( if (snapshot.hasData && snapshot.data != null) {
builder: (context) { count = snapshot.data!;
return const StartNewChatView(); }
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),
), ),
), ),
); );

View file

@ -1,5 +1,4 @@
import 'dart:async'; import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:mutex/mutex.dart'; import 'package:mutex/mutex.dart';

View file

@ -66,7 +66,7 @@ class _ContextMenuState extends State<ContextMenu> {
leading: _getIcon(item.icon), leading: _getIcon(item.icon),
), ),
), ),
) ),
], ],
position: RelativeRect.fromRect( position: RelativeRect.fromRect(
_tapPosition! & const Size(40, 40), _tapPosition! & const Size(40, 40),