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 all 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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 21. Listen to presence status
# 22. Listen to presence status

Date: 2024-04-08

Expand Down Expand Up @@ -61,4 +61,4 @@ Here `lastActivePresence` is updated for each items in `sync.presence` list if i
if (lastActivePresence != null) {
onlatestPresenceChanged.add(lastActivePresence);
}
```
```
16 changes: 16 additions & 0 deletions docs/adr/0023-change-open-file-package.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# 23. Change open file package

Date: 2024-05-13

## Status

Accepted

## Context

The package `open_file` has been used to open files on mobile versions of the app. The problem is that this package is not compatible with desktop platforms. Especially on Linux where it caused some errors and does not work. That said we could use the method `Process.run()` for each desktop platform but that might complexify a lot the process.

## Decision

A fork of `open_file` has been made, named `open_file_app` (https://pub.dev/packages/open_app_file). A fix has been made for Linux https://github.com/yendoplan/open_app_file/pull/5 which is the branch we will use until it will be merged by the maintainers.
Since it's a fork, the methods are the same than `open_file` and works the same way.
37 changes: 37 additions & 0 deletions docs/adr/0024-oidc-mechanism-on-desktop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# 24. OIDC mechanism on desktop

Date: 2024-05-13

## Status

Accepted

## Context

Currently OIDC is handled for web and mobile versions of the application. For web `FlutterWebAuth2` uses an `iframe` to watch the result of the log in process wether it's a success, or a timeout. For the case of mobile app, the app registered a url scheme which looks like `myapp://auth`. This scheme is where the OIDC server will send its result which will be retrieved by the app like a deeplink.

But we can't use an `iframe` or register a custom url on desktop applications (at least for linux and windows). So we have to find an other solution to catch the result from the browser where the user log in.

## Decision

To achieve that the app (via `FlutterWebAuth2`) sets a light webserver on the user's device. This server's URI, which looks like `http://localhost:port`, uses on a random open port and is sent to OIDC server as form url encoded content. This port is found using this method:

```dart
Future<int> findFreePort() async {
// launch a local light web server
// to find a random open open, we set port as 0
final tmpServer = await ServerSocket.bind(InternetAddress.loopbackIPv4, 0);
final port = tmpServer.port;
// when an open port as been found tmp server is closed and port is returned
await tmpServer.close();
return port;
}
```

The app listens to this server, looking for a result. If log in succeed, the OIDC server `POST` the access token to this server which send it to the app.
As soon as the log in process is done (wether it's successful or not), the webserver is closed.

More details:
- https://github.com/ThexXTURBOXx/flutter_web_auth_2/blob/b48b6f5c866b8c1018cc138b2b11acb3b6188e0b/flutter_web_auth_2/lib/src/server.dart
- https://blog.logto.io/redirect-uri-in-authorization-code-flow/
- https://openid.net/developers/how-connect-works/
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.isDesktop
? 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
}
7 changes: 5 additions & 2 deletions lib/pages/chat/chat.dart
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ class ChatController extends State<Chat>

void handleDragDone(DropDoneDetails details) async {
final matrixFiles = await onDragDone(details);
sendFileOnWebAction(context, room: room, matrixFilesList: matrixFiles);
openSendFileDialogAction(context, room: room, matrixFilesList: matrixFiles);
}

void _handleReceivedShareFiles() {
Expand Down Expand Up @@ -1284,9 +1284,12 @@ 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();
openSendFileDialogAction(context, room: room, matrixFilesList: matrixFiles);
} else {
final matrixFiles = await pickFilesFromSystem();
sendFileOnWebAction(context, room: room, matrixFilesList: matrixFiles);
openSendFileDialogAction(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
Loading
Loading