formatting

This commit is contained in:
Steef Hegeman 2021-05-26 20:50:15 +02:00
parent 24b632fc90
commit a67de58d9a
2 changed files with 868 additions and 838 deletions

View File

@ -27,219 +27,219 @@ class ChatListView extends StatelessWidget {
? SelectMode.normal ? SelectMode.normal
: SelectMode.select; : SelectMode.select;
return VWidgetGuard( return VWidgetGuard(
onSystemPop: (redirector) async { onSystemPop: (redirector) async {
if (controller.selectedRoomIds.isNotEmpty) { if (controller.selectedRoomIds.isNotEmpty) {
controller.cancelAction(); controller.cancelAction();
redirector.stopRedirection(); redirector.stopRedirection();
} }
}, },
child: child: Scaffold(
Scaffold( appBar: AppBar(
appBar: AppBar( elevation: MediaQuery.of(context).size.width >
elevation: MediaQuery.of(context).size.width > FluffyThemes.columnWidth * 2
FluffyThemes.columnWidth * 2 ? 1
? 1 : null,
: null, leading: selectMode == SelectMode.normal
leading: selectMode == SelectMode.normal ? null
? null : IconButton(
: IconButton( tooltip: L10n.of(context).cancel,
tooltip: L10n.of(context).cancel, icon: Icon(Icons.close_outlined),
icon: Icon(Icons.close_outlined), onPressed: controller.cancelAction,
onPressed: controller.cancelAction, ),
), centerTitle: false,
centerTitle: false, actions: selectMode == SelectMode.share
actions: selectMode == SelectMode.share ? null
? null : selectMode == SelectMode.select
: selectMode == SelectMode.select ? [
? [ if (controller.selectedRoomIds.length == 1)
if (controller.selectedRoomIds.length == 1) IconButton(
IconButton( tooltip: L10n.of(context).toggleUnread,
tooltip: L10n.of(context).toggleUnread, icon: Icon(Matrix.of(context)
icon: Icon(Matrix.of(context)
.client
.getRoomById(
controller.selectedRoomIds.single)
.isUnread
? Icons.mark_chat_read_outlined
: Icons.mark_chat_unread_outlined),
onPressed: controller.toggleUnread,
),
if (controller.selectedRoomIds.length == 1)
IconButton(
tooltip: L10n.of(context).toggleFavorite,
icon: Icon(Icons.push_pin_outlined),
onPressed: controller.toggleFavouriteRoom,
),
if (controller.selectedRoomIds.length == 1)
IconButton(
icon: Icon(Matrix.of(context)
.client .client
.getRoomById( .getRoomById(
controller.selectedRoomIds.single) controller.selectedRoomIds.single)
.pushRuleState == .isUnread
PushRuleState.notify ? Icons.mark_chat_read_outlined
? Icons.notifications_off_outlined : Icons.mark_chat_unread_outlined),
: Icons.notifications_outlined), onPressed: controller.toggleUnread,
tooltip: L10n.of(context).toggleMuted,
onPressed: controller.toggleMuted,
),
IconButton(
icon: Icon(Icons.archive_outlined),
tooltip: L10n.of(context).archive,
onPressed: controller.archiveAction,
),
]
: [
IconButton(
icon: Icon(Icons.search_outlined),
tooltip: L10n.of(context).search,
onPressed: () =>
VRouter.of(context).push('/search'),
),
PopupMenuButton<PopupMenuAction>(
onSelected: controller.onPopupMenuSelect,
itemBuilder: (_) => [
PopupMenuItem(
value: PopupMenuAction.setStatus,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.edit_outlined),
SizedBox(width: 12),
Text(L10n.of(context).setStatus),
],
), ),
), if (controller.selectedRoomIds.length == 1)
PopupMenuItem( IconButton(
value: PopupMenuAction.newGroup, tooltip: L10n.of(context).toggleFavorite,
child: Row( icon: Icon(Icons.push_pin_outlined),
mainAxisSize: MainAxisSize.min, onPressed: controller.toggleFavouriteRoom,
children: [
Icon(Icons.group_add_outlined),
SizedBox(width: 12),
Text(L10n.of(context).createNewGroup),
],
), ),
), if (controller.selectedRoomIds.length == 1)
PopupMenuItem( IconButton(
value: PopupMenuAction.invite, icon: Icon(Matrix.of(context)
child: Row( .client
mainAxisSize: MainAxisSize.min, .getRoomById(controller
children: [ .selectedRoomIds.single)
Icon(Icons.share_outlined), .pushRuleState ==
SizedBox(width: 12), PushRuleState.notify
Text(L10n.of(context).inviteContact), ? Icons.notifications_off_outlined
], : Icons.notifications_outlined),
tooltip: L10n.of(context).toggleMuted,
onPressed: controller.toggleMuted,
), ),
IconButton(
icon: Icon(Icons.archive_outlined),
tooltip: L10n.of(context).archive,
onPressed: controller.archiveAction,
), ),
PopupMenuItem( ]
value: PopupMenuAction.archive, : [
child: Row( IconButton(
mainAxisSize: MainAxisSize.min, icon: Icon(Icons.search_outlined),
children: [ tooltip: L10n.of(context).search,
Icon(Icons.archive_outlined), onPressed: () =>
SizedBox(width: 12), VRouter.of(context).push('/search'),
Text(L10n.of(context).archive),
],
),
), ),
PopupMenuItem( PopupMenuButton<PopupMenuAction>(
value: PopupMenuAction.settings, onSelected: controller.onPopupMenuSelect,
child: Row( itemBuilder: (_) => [
mainAxisSize: MainAxisSize.min, PopupMenuItem(
children: [ value: PopupMenuAction.setStatus,
Icon(Icons.settings_outlined), child: Row(
SizedBox(width: 12), mainAxisSize: MainAxisSize.min,
Text(L10n.of(context).settings), children: [
], Icon(Icons.edit_outlined),
), SizedBox(width: 12),
), Text(L10n.of(context).setStatus),
], ],
), ),
],
title: Text(selectMode == SelectMode.share
? L10n.of(context).share
: selectMode == SelectMode.select
? L10n.of(context).numberSelected(
controller.selectedRoomIds.length.toString())
: AppConfig.applicationName),
),
body: Column(children: [
ConnectionStatusHeader(),
Expanded(
child: StreamBuilder(
stream: Matrix.of(context)
.client
.onSync
.stream
.where((s) => s.hasRoomUpdate),
builder: (context, snapshot) {
return FutureBuilder<void>(
future: controller.waitForFirstSync(),
builder: (BuildContext context, snapshot) {
if (snapshot.hasData) {
final rooms = List<Room>.from(
Matrix.of(context).client.rooms);
rooms.removeWhere((room) => room.lastEvent == null);
if (rooms.isEmpty) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Icon(
Icons.maps_ugc_outlined,
size: 80,
color: Colors.grey,
), ),
Center( PopupMenuItem(
child: Text( value: PopupMenuAction.newGroup,
L10n.of(context).startYourFirstChat, child: Row(
textAlign: TextAlign.start, mainAxisSize: MainAxisSize.min,
style: TextStyle( children: [
color: Colors.grey, Icon(Icons.group_add_outlined),
fontSize: 16, SizedBox(width: 12),
), Text(L10n.of(context).createNewGroup),
],
),
),
PopupMenuItem(
value: PopupMenuAction.invite,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.share_outlined),
SizedBox(width: 12),
Text(L10n.of(context).inviteContact),
],
),
),
PopupMenuItem(
value: PopupMenuAction.archive,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.archive_outlined),
SizedBox(width: 12),
Text(L10n.of(context).archive),
],
),
),
PopupMenuItem(
value: PopupMenuAction.settings,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.settings_outlined),
SizedBox(width: 12),
Text(L10n.of(context).settings),
],
), ),
), ),
], ],
);
}
final totalCount = rooms.length;
return ListView.builder(
itemCount: totalCount,
itemBuilder: (BuildContext context, int i) =>
ChatListItem(
rooms[i],
selected: controller.selectedRoomIds
.contains(rooms[i].id),
onTap: selectMode == SelectMode.select
? () =>
controller.toggleSelection(rooms[i].id)
: null,
onLongPress: () =>
controller.toggleSelection(rooms[i].id),
activeChat:
controller.activeChat == rooms[i].id,
), ),
); ],
} else { title: Text(selectMode == SelectMode.share
return Center( ? L10n.of(context).share
child: CircularProgressIndicator(), : selectMode == SelectMode.select
); ? L10n.of(context).numberSelected(
} controller.selectedRoomIds.length.toString())
}, : AppConfig.applicationName),
); ),
}), body: Column(children: [
), ConnectionStatusHeader(),
]), Expanded(
floatingActionButton: selectMode == SelectMode.normal child: StreamBuilder(
? FloatingActionButton( stream: Matrix.of(context)
onPressed: () => .client
VRouter.of(context).push('/newprivatechat'), .onSync
child: Icon(CupertinoIcons.chat_bubble), .stream
) .where((s) => s.hasRoomUpdate),
: null, builder: (context, snapshot) {
)); return FutureBuilder<void>(
future: controller.waitForFirstSync(),
builder: (BuildContext context, snapshot) {
if (snapshot.hasData) {
final rooms = List<Room>.from(
Matrix.of(context).client.rooms);
rooms.removeWhere(
(room) => room.lastEvent == null);
if (rooms.isEmpty) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Icon(
Icons.maps_ugc_outlined,
size: 80,
color: Colors.grey,
),
Center(
child: Text(
L10n.of(context).startYourFirstChat,
textAlign: TextAlign.start,
style: TextStyle(
color: Colors.grey,
fontSize: 16,
),
),
),
],
);
}
final totalCount = rooms.length;
return ListView.builder(
itemCount: totalCount,
itemBuilder: (BuildContext context, int i) =>
ChatListItem(
rooms[i],
selected: controller.selectedRoomIds
.contains(rooms[i].id),
onTap: selectMode == SelectMode.select
? () => controller
.toggleSelection(rooms[i].id)
: null,
onLongPress: () =>
controller.toggleSelection(rooms[i].id),
activeChat:
controller.activeChat == rooms[i].id,
),
);
} else {
return Center(
child: CircularProgressIndicator(),
);
}
},
);
}),
),
]),
floatingActionButton: selectMode == SelectMode.normal
? FloatingActionButton(
onPressed: () =>
VRouter.of(context).push('/newprivatechat'),
child: Icon(CupertinoIcons.chat_bubble),
)
: null,
));
}); });
} }
} }

File diff suppressed because it is too large Load Diff