Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Part 1] Build linux version #1730

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions assets/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -2792,6 +2792,7 @@
"downloadImageSuccess": "Image saved to Pictures",
"@downloadImageSuccess": {},
"downloadImageError": "Error saving image",
"downloadFileError": "Error downloading file",
"@downloadImageError": {},
"downloadFileInWeb": "File saved to {directory}",
"@downloadFileInWeb": {
Expand Down
1 change: 1 addition & 0 deletions assets/l10n/intl_fr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -2696,6 +2696,7 @@
"@acceptInvite": {},
"downloadImageError": "Erreur d'enregistrement de l'image",
"@downloadImageError": {},
"downloadFileError": "Erreur de téléchargement du fichier",
"externalContactMessage": "Certains des utilisateurs que vous souhaitez ajouter ne figurent pas dans vos contacts. Voulez-vous les inviter ?",
"@externalContactMessage": {},
"appLanguage": "Langue de l'application",
Expand Down
2 changes: 1 addition & 1 deletion lib/config/go_routes/go_router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ abstract class AppRoutes {
path: '/home',
pageBuilder: (context, state) => defaultPageBuilder(
context,
PlatformInfos.isMobile
PlatformInfos.isMobile || PlatformInfos.isLinux
? const TwakeWelcome()
: AutoHomeserverPicker(
loggedOut: state.extra is bool ? state.extra as bool? : null,
Expand Down
24 changes: 24 additions & 0 deletions lib/domain/model/extensions/xfile_extension.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import 'package:file_picker/file_picker.dart';
import 'package:file_selector/file_selector.dart';
import 'package:matrix/matrix.dart';

extension XFileExtension on XFile {
Future<MatrixFile> toMatrixFile() async {
return MatrixFile.fromMimeType(
bytes: await readAsBytes(),
mimeType: mimeType,
name: name,
filePath: path,
sizeInBytes: await length(),
);
}

Future<PlatformFile> toPlatformFile() async {
return PlatformFile.fromMap({
'name': name,
'path': path,
'bytes': await readAsBytes(),
Te-Z marked this conversation as resolved.
Show resolved Hide resolved
'size': await length(),
});
}
sherlockvn marked this conversation as resolved.
Show resolved Hide resolved
}
2 changes: 1 addition & 1 deletion lib/pages/bootstrap/bootstrap_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class BootstrapDialogState extends State<BootstrapDialog> {
if (PlatformInfos.isAndroid) {
return L10n.of(context)!.storeInAndroidKeystore;
}
if (PlatformInfos.isIOS || PlatformInfos.isMacOS) {
if (PlatformInfos.isIOS || PlatformInfos.isMacOS || PlatformInfos.isLinux) {
Te-Z marked this conversation as resolved.
Show resolved Hide resolved
return L10n.of(context)!.storeInAppleKeyChain;
}
return L10n.of(context)!.storeSecurlyOnThisDevice;
Expand Down
3 changes: 3 additions & 0 deletions lib/pages/chat/chat.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1284,6 +1284,9 @@ class ChatController extends State<Chat>
void onSendFileClick(BuildContext context) async {
if (PlatformInfos.isMobile) {
_showMediaPicker(context);
} else if (PlatformInfos.isDesktop) {
sherlockvn marked this conversation as resolved.
Show resolved Hide resolved
final matrixFiles = await pickFilesFromDesktop();
sendFileOnWebAction(context, room: room, matrixFilesList: matrixFiles);
Te-Z marked this conversation as resolved.
Show resolved Hide resolved
} else {
final matrixFiles = await pickFilesFromSystem();
sendFileOnWebAction(context, room: room, matrixFilesList: matrixFiles);
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/chat/chat_event_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ class SelectionTextContainer extends StatelessWidget {

@override
Widget build(BuildContext context) {
if (!PlatformInfos.isWeb) {
if (PlatformInfos.isMobile) {
return child;
}

Expand Down
80 changes: 52 additions & 28 deletions lib/pages/chat/chat_input_row.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import 'package:fluffychat/pages/chat/chat_input_row_web.dart';
import 'package:fluffychat/pages/chat/reply_display.dart';
import 'package:fluffychat/resource/image_paths.dart';
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:fluffychat/utils/shortcuts.dart';
import 'package:fluffychat/widgets/avatar/avatar.dart';
import 'package:fluffychat/widgets/matrix.dart';
import 'package:fluffychat/widgets/twake_components/twake_icon_button.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:matrix/matrix.dart';
Expand Down Expand Up @@ -98,35 +100,57 @@ class ChatInputRow extends StatelessWidget {
);
}

InputBar _buildInputBar(BuildContext context) {
return InputBar(
typeAheadKey: controller.chatComposerTypeAheadKey,
rawKeyboardFocusNode: controller.rawKeyboardListenerFocusNode,
room: controller.room!,
minLines: 1,
maxLines: 8,
autofocus: !PlatformInfos.isMobile,
keyboardType: TextInputType.multiline,
textInputAction: null,
onSubmitted: (_) => controller.onInputBarSubmitted(),
suggestionsController: controller.suggestionsController,
typeAheadFocusNode: controller.inputFocus,
controller: controller.sendController,
focusSuggestionController: controller.focusSuggestionController,
suggestionScrollController: controller.suggestionScrollController,
showEmojiPickerNotifier: controller.showEmojiPickerNotifier,
decoration: InputDecoration(
hintText: L10n.of(context)!.chatMessage,
hintMaxLines: 1,
hintStyle: Theme.of(context)
.textTheme
.bodyLarge
?.merge(
Theme.of(context).inputDecorationTheme.hintStyle,
)
.copyWith(letterSpacing: -0.15),
Widget _buildInputBar(BuildContext context) {
return Shortcuts(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it work on Web platform?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capture.video.du.14-05-2024.11.40.35.webm

shortcuts: <LogicalKeySet, Intent>{
LogicalKeySet(
LogicalKeyboardKey.controlLeft,
LogicalKeyboardKey.keyA,
): const SelectAllIntent(),
LogicalKeySet(
LogicalKeyboardKey.altLeft,
LogicalKeyboardKey.keyE,
): const OnEmojiActionIntent(),
},
child: Actions(
actions: <Type, Action<Intent>>{
SelectAllIntent: CallbackAction<SelectAllIntent>(
onInvoke: (_) => controller.selectAll(),
),
OnEmojiActionIntent: CallbackAction<OnEmojiActionIntent>(
onInvoke: (_) => controller.onEmojiAction(),
),
},
child: InputBar(
typeAheadKey: controller.chatComposerTypeAheadKey,
rawKeyboardFocusNode: controller.rawKeyboardListenerFocusNode,
room: controller.room!,
minLines: 1,
maxLines: 8,
autofocus: !PlatformInfos.isMobile,
keyboardType: TextInputType.multiline,
textInputAction: null,
onSubmitted: (_) => controller.onInputBarSubmitted(),
suggestionsController: controller.suggestionsController,
typeAheadFocusNode: controller.inputFocus,
controller: controller.sendController,
focusSuggestionController: controller.focusSuggestionController,
suggestionScrollController: controller.suggestionScrollController,
showEmojiPickerNotifier: controller.showEmojiPickerNotifier,
decoration: InputDecoration(
hintText: L10n.of(context)!.chatMessage,
hintMaxLines: 1,
hintStyle: Theme.of(context)
.textTheme
.bodyLarge
?.merge(
Theme.of(context).inputDecorationTheme.hintStyle,
)
.copyWith(letterSpacing: -0.15),
),
onChanged: controller.onInputBarChanged,
),
),
onChanged: controller.onInputBarChanged,
);
}
}
Expand Down
64 changes: 26 additions & 38 deletions lib/pages/chat/chat_input_row_mobile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import 'package:animations/animations.dart';
import 'package:fluffychat/pages/chat/chat_input_row_style.dart';
import 'package:fluffychat/widgets/twake_components/twake_icon_button.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:keyboard_shortcuts/keyboard_shortcuts.dart';
import 'package:linagora_design_flutter/linagora_design_flutter.dart';

typedef OnTapEmojiAction = void Function();
Expand Down Expand Up @@ -48,44 +46,34 @@ class ChatInputRowMobile extends StatelessWidget {
Expanded(
child: inputBar,
),
KeyBoardShortcuts(
keysToPress: {
LogicalKeyboardKey.altLeft,
LogicalKeyboardKey.keyE,
},
onKeysPressed: onEmojiAction,
helpLabel: L10n.of(context)!.emojis,
child: InkWell(
onTap: onEmojiAction,
hoverColor: Colors.transparent,
child: PageTransitionSwitcher(
transitionBuilder: (
Widget child,
Animation<double> primaryAnimation,
Animation<double> secondaryAnimation,
) {
return SharedAxisTransition(
animation: primaryAnimation,
secondaryAnimation: secondaryAnimation,
transitionType: SharedAxisTransitionType.scaled,
fillColor: Colors.transparent,
child: child,
InkWell(
onTap: onEmojiAction,
hoverColor: Colors.transparent,
child: PageTransitionSwitcher(
transitionBuilder: (
Widget child,
Animation<double> primaryAnimation,
Animation<double> secondaryAnimation,
) {
return SharedAxisTransition(
animation: primaryAnimation,
secondaryAnimation: secondaryAnimation,
transitionType: SharedAxisTransitionType.scaled,
fillColor: Colors.transparent,
child: child,
);
},
child: ValueListenableBuilder(
valueListenable: emojiPickerNotifier,
builder: (context, showEmojiPicker, child) {
return TwakeIconButton(
paddingAll:
ChatInputRowStyle.chatInputRowPaddingBtnMobile,
tooltip: L10n.of(context)!.emojis,
onTap: showEmojiPicker ? onKeyboardAction : onEmojiAction,
icon: showEmojiPicker ? Icons.keyboard : Icons.tag_faces,
);
},
child: ValueListenableBuilder(
valueListenable: emojiPickerNotifier,
builder: (context, showEmojiPicker, child) {
return TwakeIconButton(
paddingAll:
ChatInputRowStyle.chatInputRowPaddingBtnMobile,
tooltip: L10n.of(context)!.emojis,
onTap:
showEmojiPicker ? onKeyboardAction : onEmojiAction,
icon:
showEmojiPicker ? Icons.keyboard : Icons.tag_faces,
);
},
),
),
),
),
Expand Down
58 changes: 25 additions & 33 deletions lib/pages/chat/chat_input_row_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import 'package:animations/animations.dart';
import 'package:fluffychat/pages/chat/chat_input_row_style.dart';
import 'package:fluffychat/widgets/twake_components/twake_icon_button.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:keyboard_shortcuts/keyboard_shortcuts.dart';
import 'package:linagora_design_flutter/colors/linagora_ref_colors.dart';
import 'package:linagora_design_flutter/colors/linagora_sys_colors.dart';

Expand Down Expand Up @@ -54,39 +52,33 @@ class ChatInputRowWeb extends StatelessWidget {
Expanded(
child: inputBar,
),
KeyBoardShortcuts(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because Shortcuts are now in _buildInputBar which is a child widget of ChatInputRowWeb. This allow to use shortcuts whenever the input bar is used. Also this widget did not work. My thought is that it used the wrong focus scope when put inside chat_input_row_web.dart

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here the related lines:

ChatInputRowMobile _buildMobileInputRow(BuildContext context) {
return ChatInputRowMobile(
inputBar: Column(
children: [
ReplyDisplay(controller),
_buildInputBar(context),
],
),
emojiPickerNotifier: controller.showEmojiPickerNotifier,
onEmojiAction: controller.onEmojiAction,
onKeyboardAction: controller.onKeyboardAction,
);
}
ChatInputRowWeb _buildWebInputRow(BuildContext context) {
return ChatInputRowWeb(
inputBar: Column(
children: [
ReplyDisplay(controller),
_buildInputBar(context),
],
),
emojiPickerNotifier: controller.showEmojiPickerNotifier,
onTapMoreBtn: () => controller.onSendFileClick(context),
onEmojiAction: controller.onEmojiAction,
onKeyboardAction: controller.onKeyboardAction,
);
}
Widget _buildInputBar(BuildContext context) {
return Shortcuts(
shortcuts: <LogicalKeySet, Intent>{
LogicalKeySet(
LogicalKeyboardKey.controlLeft,
LogicalKeyboardKey.keyA,
): const SelectAllIntent(),
LogicalKeySet(
LogicalKeyboardKey.altLeft,
LogicalKeyboardKey.keyE,
): const OnEmojiActionIntent(),
},
child: Actions(
actions: <Type, Action<Intent>>{
SelectAllIntent: CallbackAction<SelectAllIntent>(
onInvoke: (_) => controller.selectAll(),
),
OnEmojiActionIntent: CallbackAction<OnEmojiActionIntent>(
onInvoke: (_) => controller.onEmojiAction(),
),
},
child: InputBar(
typeAheadKey: controller.chatComposerTypeAheadKey,
rawKeyboardFocusNode: controller.rawKeyboardListenerFocusNode,
room: controller.room!,
minLines: 1,
maxLines: 8,
autofocus: !PlatformInfos.isMobile,
keyboardType: TextInputType.multiline,
textInputAction: null,
onSubmitted: (_) => controller.onInputBarSubmitted(),
suggestionsController: controller.suggestionsController,
typeAheadFocusNode: controller.inputFocus,
controller: controller.sendController,
focusSuggestionController: controller.focusSuggestionController,
suggestionScrollController: controller.suggestionScrollController,
showEmojiPickerNotifier: controller.showEmojiPickerNotifier,
decoration: InputDecoration(
hintText: L10n.of(context)!.chatMessage,
hintMaxLines: 1,
hintStyle: Theme.of(context)
.textTheme
.bodyLarge
?.merge(
Theme.of(context).inputDecorationTheme.hintStyle,
)
.copyWith(letterSpacing: -0.15),
),
onChanged: controller.onInputBarChanged,
),
),
);
}
}

keysToPress: {LogicalKeyboardKey.altLeft, LogicalKeyboardKey.keyE},
onKeysPressed: onEmojiAction,
helpLabel: L10n.of(context)!.emojis,
child: InkWell(
onTap: onEmojiAction,
hoverColor: Colors.transparent,
child: PageTransitionSwitcher(
transitionBuilder: (
Widget child,
Animation<double> primaryAnimation,
Animation<double> secondaryAnimation,
) {
return SharedAxisTransition(
animation: primaryAnimation,
secondaryAnimation: secondaryAnimation,
transitionType: SharedAxisTransitionType.scaled,
fillColor: Colors.transparent,
child: child,
InkWell(
onTap: onEmojiAction,
hoverColor: Colors.transparent,
child: PageTransitionSwitcher(
transitionBuilder: (
Widget child,
Animation<double> primaryAnimation,
Animation<double> secondaryAnimation,
) {
return SharedAxisTransition(
animation: primaryAnimation,
secondaryAnimation: secondaryAnimation,
transitionType: SharedAxisTransitionType.scaled,
fillColor: Colors.transparent,
child: child,
);
},
child: ValueListenableBuilder(
valueListenable: emojiPickerNotifier,
builder: (context, showEmojiPicker, child) {
return TwakeIconButton(
paddingAll: ChatInputRowStyle.chatInputRowPaddingBtnMobile,
tooltip: L10n.of(context)!.emojis,
onTap: showEmojiPicker ? onKeyboardAction : onEmojiAction,
icon: showEmojiPicker ? Icons.keyboard : Icons.tag_faces,
);
},
child: ValueListenableBuilder(
valueListenable: emojiPickerNotifier,
builder: (context, showEmojiPicker, child) {
return TwakeIconButton(
paddingAll:
ChatInputRowStyle.chatInputRowPaddingBtnMobile,
tooltip: L10n.of(context)!.emojis,
onTap: showEmojiPicker ? onKeyboardAction : onEmojiAction,
icon: showEmojiPicker ? Icons.keyboard : Icons.tag_faces,
);
},
),
),
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class MultiPlatformsMessageContainer extends StatelessWidget {

@override
Widget build(BuildContext context) {
if (PlatformInfos.isWeb) {
if (PlatformInfos.isWebOrDesktop) {
return MouseRegion(
child: child,
onHover: (event) {
Expand Down
6 changes: 3 additions & 3 deletions lib/pages/chat/events/message_content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class MessageContent extends StatelessWidget
return Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
if (!PlatformInfos.isWeb) ...[
if (PlatformInfos.isMobile) ...[
MessageDownloadContent(
event,
),
Expand All @@ -126,7 +126,7 @@ class MessageContent extends StatelessWidget
return Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
if (!PlatformInfos.isWeb) ...[
if (PlatformInfos.isMobile || PlatformInfos.isDesktop) ...[
MessageDownloadContent(
event,
),
Expand Down Expand Up @@ -317,7 +317,7 @@ class _MessageImageBuilder extends StatelessWidget {
return matrixFile != null &&
matrixFile.filePath != null &&
matrixFile is MatrixImageFile &&
!PlatformInfos.isWeb;
!PlatformInfos.isWebOrDesktop;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ class ChatAdaptiveScaffoldBuilderController
builder: (_) => Stack(
children: [
body!,
if (rightColumnType != null && PlatformInfos.isWeb)
if (rightColumnType != null &&
PlatformInfos.isWebOrDesktop)
widget.rightBuilder(
this,
isInStack: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class _VideoItem extends StatelessWidget {
Future<void> _onTapVideo(BuildContext context) async {
final result = await Navigator.of(
context,
rootNavigator: PlatformInfos.isWeb,
rootNavigator: PlatformInfos.isWebOrDesktop,
).push(
HeroPageRoute(
builder: (context) {
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/chat_list/chat_list_header.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ChatListHeader extends StatelessWidget {
Container(
height: ChatListHeaderStyle.searchBarContainerHeight,
padding: ChatListHeaderStyle.searchInputPadding,
child: PlatformInfos.isWeb
child: PlatformInfos.isWebOrDesktop
? _normalModeWidgetWeb(context)
: _normalModeWidgetsMobile(context),
),
Expand Down
Loading
Loading