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 2] build linux version #1745

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
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(),
'size': await length(),
});
}
}
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) {
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) {
final matrixFiles = await pickFilesFromDesktop();
sendFileOnWebAction(context, room: room, matrixFilesList: matrixFiles);
} 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(
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(
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
Loading
Loading