Skip to content

Commit

Permalink
chore: refactor to be a bit more picky in directory structure + flutt…
Browse files Browse the repository at this point in the history
…er 3.27.2
  • Loading branch information
Feichtmeier committed Jan 14, 2025
1 parent e2e4a9c commit 73fdd51
Show file tree
Hide file tree
Showing 96 changed files with 1,069 additions and 802 deletions.
18 changes: 11 additions & 7 deletions lib/app/view/app.dart
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import 'dart:io';
import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:system_theme/system_theme_builder.dart';
import 'package:yaru/yaru.dart';

import '../../chat/view/chat_start_page.dart';
import '../../chat/chat_start_page.dart';
import '../../constants.dart';
import '../../l10n/l10n.dart';

class NebuchadnezzarApp extends StatelessWidget {
const NebuchadnezzarApp({super.key});
const NebuchadnezzarApp({super.key, required this.yaruApp});

final bool yaruApp;

@override
Widget build(BuildContext context) => Platform.isLinux
Widget build(BuildContext context) => yaruApp
? YaruTheme(
builder: (context, yaru, child) => App(
lightTheme: yaru.theme,
Expand All @@ -21,9 +23,11 @@ class NebuchadnezzarApp extends StatelessWidget {
highContrastDarkTheme: yaruHighContrastDark,
),
)
: App(
lightTheme: yaruLight,
darkTheme: yaruDark,
: SystemThemeBuilder(
builder: (context, systemColor) => App(
lightTheme: createYaruLightTheme(primaryColor: systemColor.accent),
darkTheme: createYaruDarkTheme(primaryColor: systemColor.accent),
),
);
}

Expand Down
8 changes: 0 additions & 8 deletions lib/app_config.dart

This file was deleted.

2 changes: 1 addition & 1 deletion lib/chat/authentication/chat_login_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import '../../common/view/space.dart';
import '../../common/view/ui_constants.dart';
import '../../constants.dart';
import '../../l10n/l10n.dart';
import '../view/chat_master/chat_master_detail_page.dart';
import '../chat_master/view/chat_master_detail_page.dart';
import 'authentication_model.dart';

class ChatLoginPage extends StatefulWidget with WatchItStatefulWidgetMixin {
Expand Down
4 changes: 2 additions & 2 deletions lib/chat/bootstrap/view/key_verification_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import 'package:yaru/yaru.dart';

import '../../../common/view/build_context_x.dart';
import '../../../l10n/l10n.dart';
import '../../view/chat_avatar.dart';
import '../../view/chat_master/chat_master_detail_page.dart';
import '../../common/view/chat_avatar.dart';
import '../../chat_master/view/chat_master_detail_page.dart';

// Credit: this code has been initially copied from https://github.com/krille-chan/fluffychat
// Thank you @krille-chan
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:watch_it/watch_it.dart';

import '../../../common/view/build_context_x.dart';
import '../../chat_model.dart';
import '../../common/chat_model.dart';

// TODO: move this to a registerStreamHandler -> send to operating system
class ChatAllUnreadRoomsBadge extends StatelessWidget {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import '../../../common/view/ui_constants.dart';
import '../../bootstrap/bootstrap_model.dart';
import '../../bootstrap/view/bootstrap_page.dart';
import '../../bootstrap/view/key_verification_dialog.dart';
import '../../chat_model.dart';
import '../chat_room/chat_room_page.dart';
import '../no_selected_room_page.dart';
import '../../common/chat_model.dart';
import '../../chat_room/common/view/chat_room_page.dart';
import '../../chat_room/common/view/chat_no_selected_room_page.dart';
import 'chat_master_panel.dart';

final GlobalKey<ScaffoldState> masterScaffoldKey = GlobalKey();
Expand Down Expand Up @@ -100,7 +100,7 @@ class _ChatMasterDetailPageState extends State<ChatMasterDetailPage> {
),
)
else if (selectedRoom == null)
const Expanded(child: NoSelectedRoomPage())
const Expanded(child: ChatNoSelectedRoomPage())
else
Expanded(
child: ChatRoomPage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,23 @@ import 'package:flutter/material.dart';
import 'package:watch_it/watch_it.dart';
import 'package:yaru/yaru.dart';

import '../../../common/view/sliver_sticky_panel.dart';
import '../../../common/view/ui_constants.dart';
import '../../../l10n/l10n.dart';
import '../../chat_model.dart';
import '../../rooms_filter.dart';
import '../../common/chat_model.dart';
import '../../common/rooms_filter.dart';

class ChatMasterListFilterBar extends StatelessWidget with WatchItMixin {
const ChatMasterListFilterBar({super.key});

@override
Widget build(BuildContext context) {
final roomsFilter = watchPropertyValue((ChatModel m) => m.roomsFilter);
return SliverStickyPanel(
return Padding(
padding: const EdgeInsets.only(
left: kMediumPlusPadding,
right: kMediumPlusPadding,
bottom: kMediumPadding,
),
child: YaruChoiceChipBar(
showCheckMarks: false,
shrinkWrap: false,
Expand Down
101 changes: 101 additions & 0 deletions lib/chat/chat_master/view/chat_master_panel.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import 'package:flutter/material.dart';
import 'package:watch_it/watch_it.dart';
import 'package:yaru/yaru.dart';

import '../../../common/view/build_context_x.dart';
import '../../../common/view/common_widgets.dart';
import '../../../common/view/theme.dart';
import '../../../common/view/ui_constants.dart';
import '../../../l10n/l10n.dart';
import '../../common/chat_model.dart';
import '../../common/rooms_filter.dart';
import '../../common/search_model.dart';
import '../../common/view/search_auto_complete.dart';
import '../../settings/settings_dialog.dart';
import 'chat_master_list_filter_bar.dart';
import 'chat_master_title_bar.dart';
import 'chat_rooms_list.dart';
import 'chat_space_control_panel.dart';
import 'chat_space_filter.dart';

class ChatMasterSidePanel extends StatelessWidget with WatchItMixin {
const ChatMasterSidePanel({super.key});

@override
Widget build(BuildContext context) {
final l10n = context.l10n;
final searchModel = di<SearchModel>();
final searchActive = watchPropertyValue((SearchModel m) => m.searchActive);
final searchType = watchPropertyValue((SearchModel m) => m.searchType);
final archiveActive = watchPropertyValue((ChatModel m) => m.archiveActive);
final loadingArchive =
watchPropertyValue((ChatModel m) => m.loadingArchive);
final roomsFilter = watchPropertyValue((ChatModel m) => m.roomsFilter);

final suffix = IconButton(
padding: EdgeInsets.zero,
style: textFieldSuffixStyle,
onPressed: () => searchModel.setSearchType(
switch (searchType) {
SearchType.profiles => SearchType.rooms,
SearchType.rooms => SearchType.spaces,
SearchType.spaces => SearchType.profiles,
},
),
icon: switch (searchType) {
SearchType.profiles => const Icon(YaruIcons.user),
SearchType.rooms => const Icon(YaruIcons.users),
SearchType.spaces => const Icon(YaruIcons.globe)
},
);

return Material(
color: getPanelBg(context.theme),
child: Column(
children: [
const ChatMasterTitleBar(),
if (searchActive && !archiveActive)
Padding(
padding: const EdgeInsets.only(
left: kMediumPlusPadding,
right: kMediumPlusPadding,
bottom: kMediumPadding,
),
child: switch (searchType) {
SearchType.profiles => ChatUserSearchAutoComplete(
suffix: suffix,
),
_ => RoomsAutoComplete(
suffix: suffix,
)
},
),
const ChatMasterListFilterBar(),
if (roomsFilter == RoomsFilter.spaces && !archiveActive)
const ChatSpaceFilter(),
if (roomsFilter == RoomsFilter.spaces && !archiveActive)
const ChatSpaceControlPanel(),
if (loadingArchive)
const Expanded(
child: Center(child: Progress()),
)
else
const Expanded(
child: ChatRoomsList(),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: kMediumPadding),
child: YaruMasterTile(
leading: const Icon(YaruIcons.settings),
title: Text(l10n.settings),
onTap: () => showDialog(
context: context,
builder: (context) => const SettingsDialog(),
),
),
),
],
),
);
}
}
53 changes: 53 additions & 0 deletions lib/chat/chat_master/view/chat_master_title_bar.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import 'package:flutter/material.dart';
import 'package:watch_it/watch_it.dart';
import 'package:yaru/yaru.dart';

import '../../../common/view/build_context_x.dart';
import '../../../common/view/space.dart';
import '../../../common/view/theme.dart';
import '../../../common/view/ui_constants.dart';
import '../../../l10n/l10n.dart';
import '../../common/chat_model.dart';
import '../../common/search_model.dart';
import 'chat_new_chat_popup_menu_button.dart';

class ChatMasterTitleBar extends StatelessWidget with WatchItMixin {
const ChatMasterTitleBar({super.key});

@override
Widget build(BuildContext context) {
final l10n = context.l10n;
final chatModel = di<ChatModel>();
final searchModel = di<SearchModel>();
final searchActive = watchPropertyValue((SearchModel m) => m.searchActive);
final archiveActive = watchPropertyValue((ChatModel m) => m.archiveActive);
return YaruWindowTitleBar(
heroTag: '<Left hero tag>',
title: Text(archiveActive ? l10n.archive : l10n.chats),
border: BorderSide.none,
style: YaruTitleBarStyle.undecorated,
backgroundColor: getMonochromeBg(theme: context.theme, darkFactor: 3),
actions: space(
flex: true,
spaceEnd: true,
widthGap: kSmallPadding,
skip: 0,
children: [
if (!archiveActive) const ChatNewChatPopupMenuButton(),
if (!archiveActive)
IconButton(
isSelected: searchActive,
onPressed: searchModel.toggleSearch,
icon: const Icon(YaruIcons.search),
),
IconButton(
selectedIcon: const Icon(YaruIcons.bookmark_filled),
isSelected: archiveActive,
onPressed: chatModel.toggleArchive,
icon: const Icon(YaruIcons.bookmark),
),
],
),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import '../../../common/view/common_widgets.dart';
import '../../../common/view/snackbars.dart';
import '../../../l10n/l10n.dart';
import '../../settings/settings_model.dart';
import '../chat_avatar.dart';
import '../../common/view/chat_avatar.dart';

class ChatMyUserAvatar extends StatelessWidget with WatchItMixin {
const ChatMyUserAvatar({
Expand Down
69 changes: 69 additions & 0 deletions lib/chat/chat_master/view/chat_new_chat_popup_menu_button.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import 'package:flutter/material.dart';
import 'package:yaru/yaru.dart';

import '../../../l10n/l10n.dart';
import '../../chat_room/common/view/chat_create_or_edit_room_dialog.dart';
import '../../chat_room/common/view/chat_new_direct_chat_dialog.dart';

class ChatNewChatPopupMenuButton extends StatelessWidget {
const ChatNewChatPopupMenuButton({super.key});

@override
Widget build(BuildContext context) {
final l10n = context.l10n;
return PopupMenuButton(
tooltip: l10n.newChat,
padding: EdgeInsets.zero,
icon: const Icon(YaruIcons.plus),
itemBuilder: (context) {
return [
PopupMenuItem(
onTap: () => showDialog(
context: context,
builder: (context) => const ChatNewDirectChatDialog(),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(l10n.directChat),
const Icon(
YaruIcons.user,
),
],
),
),
PopupMenuItem(
onTap: () => showDialog(
context: context,
builder: (context) => const ChatCreateOrEditRoomDialog(),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(l10n.newGroup),
const Icon(
YaruIcons.users,
),
],
),
),
PopupMenuItem(
onTap: () => showDialog(
context: context,
builder: (context) => const ChatCreateOrEditRoomDialog(
space: true,
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(l10n.newSpace),
const Icon(YaruIcons.globe),
],
),
),
];
},
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import '../../../common/view/scaffold_state_x.dart';
import '../../../common/view/snackbars.dart';
import '../../../common/view/ui_constants.dart';
import '../../../l10n/l10n.dart';
import '../../chat_model.dart';
import '../../draft_model.dart';
import '../chat_avatar.dart';
import '../chat_invitation_dialog.dart';
import '../chat_room/chat_room_master_tile_subtitle.dart';
import '../../common/chat_model.dart';
import '../../chat_room/input/draft_model.dart';
import '../../common/view/chat_avatar.dart';
import '../../chat_room/common/view/chat_invitation_dialog.dart';
import '../../chat_room/common/view/chat_room_master_tile_subtitle.dart';
import 'chat_master_detail_page.dart';

class ChatRoomMasterTile extends StatelessWidget with WatchItMixin {
Expand Down
Loading

0 comments on commit 73fdd51

Please sign in to comment.