-
Couldn't load subscription status.
- Fork 35
[Part 1] Build linux version #1730
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
base: main
Are you sure you want to change the base?
Changes from all commits
ede88d3
bf0590d
04216db
9beaebe
74fdc65
71d03d3
7ca19a8
b7cec7a
0272691
91419cf
ab5da59
059f1e4
4ae5c04
56c7470
1494bdf
51c900b
0a9b803
2341ece
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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. |
| 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/ |
| 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(), | ||
| }); | ||
| } | ||
sherlockvn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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'; | ||
|
|
@@ -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( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it work on Web platform? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes There was a problem hiding this comment. Choose a reason for hiding this commentThe 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, | ||
| ); | ||
| } | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.