mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-09-01 07:24:07 +00:00
fix share link
This commit is contained in:
parent
60c553e53c
commit
dbe48b5802
4 changed files with 32 additions and 11 deletions
|
|
@ -161,6 +161,7 @@ class _AppMainWidgetState extends State<AppMainWidget> {
|
|||
initAsync();
|
||||
|
||||
void handleShareLink(Uri uri) {
|
||||
HomeViewState.pendingSharedLink = uri;
|
||||
routerProvider.go(Routes.home);
|
||||
HomeViewState.streamHomeViewPageIndex.add(1);
|
||||
HomeViewState.streamSharedLink.add(uri);
|
||||
|
|
|
|||
|
|
@ -23,7 +23,8 @@ class CameraScannedOverlay extends StatelessWidget {
|
|||
width: 150,
|
||||
child: ListView(
|
||||
children: [
|
||||
if (mainController.scannedUrl != null)
|
||||
if (mainController.scannedUrl != null &&
|
||||
mainController.scannedUrl!.isNotEmpty)
|
||||
_buildScannedUrlTile(context, mainController.scannedUrl!),
|
||||
],
|
||||
),
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ class MainCameraController {
|
|||
}
|
||||
|
||||
void onImageSend() {
|
||||
scannedUrl = '';
|
||||
scannedUrl = null;
|
||||
setState?.call();
|
||||
}
|
||||
|
||||
|
|
@ -210,7 +210,9 @@ class MainCameraController {
|
|||
await _initializeFuture;
|
||||
} on CameraException catch (e) {
|
||||
// If specific image format is unsupported on this hardware, fallback to default format
|
||||
Log.warn('Initial camera format initialization failed ($e), trying fallback format...');
|
||||
Log.warn(
|
||||
'Initial camera format initialization failed ($e), trying fallback format...',
|
||||
);
|
||||
await controller.dispose();
|
||||
controller = CameraController(
|
||||
AppEnvironment.cameras[cameraId],
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ class HomeViewState extends State<HomeView> with WidgetsBindingObserver {
|
|||
StreamSubscription<int>? _homeViewPageIndexSub;
|
||||
StreamSubscription<NotificationResponse>? _selectNotificationSub;
|
||||
|
||||
static Uri? pendingSharedLink;
|
||||
static final streamHomeViewPageIndex = StreamController<int>.broadcast();
|
||||
static final streamSharedLink = StreamController<Uri>.broadcast();
|
||||
|
||||
|
|
@ -56,7 +57,10 @@ class HomeViewState extends State<HomeView> with WidgetsBindingObserver {
|
|||
super.initState();
|
||||
WidgetsBinding.instance.addObserver(this);
|
||||
var initialPage = widget.initialPage;
|
||||
if (initialPage == 1 && !userService.currentUser.startWithCameraOpen) {
|
||||
if (HomeViewState.pendingSharedLink != null) {
|
||||
initialPage = 1;
|
||||
} else if (initialPage == 1 &&
|
||||
!userService.currentUser.startWithCameraOpen) {
|
||||
initialPage = 0;
|
||||
}
|
||||
_activePageIdx = initialPage;
|
||||
|
|
@ -100,6 +104,22 @@ class HomeViewState extends State<HomeView> with WidgetsBindingObserver {
|
|||
streamHomeViewPageIndex.add(0);
|
||||
});
|
||||
|
||||
_sharedLinkSub = streamSharedLink.stream.listen((uri) {
|
||||
HomeViewState.pendingSharedLink = null;
|
||||
_mainCameraController.setSharedLinkForPreview(uri);
|
||||
Permission.camera.isGranted.then((hasPermission) {
|
||||
if (hasPermission && mounted) {
|
||||
unawaited(_mainCameraController.selectCamera(0, true));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
if (HomeViewState.pendingSharedLink != null) {
|
||||
final link = HomeViewState.pendingSharedLink!;
|
||||
HomeViewState.pendingSharedLink = null;
|
||||
_mainCameraController.setSharedLinkForPreview(link);
|
||||
}
|
||||
|
||||
if (initialPage == 1) {
|
||||
Permission.camera.isGranted.then((hasPermission) {
|
||||
if (hasPermission && mounted) {
|
||||
|
|
@ -110,14 +130,11 @@ class HomeViewState extends State<HomeView> with WidgetsBindingObserver {
|
|||
|
||||
unawaited(_initAsync());
|
||||
|
||||
_sharedLinkSub = streamSharedLink.stream.listen(
|
||||
_mainCameraController.setSharedLinkForPreview,
|
||||
);
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (widget.initialPage == 1 &&
|
||||
!userService.currentUser.startWithCameraOpen ||
|
||||
widget.initialPage == 0) {
|
||||
if (_mainCameraController.sharedLinkForPreview == null &&
|
||||
((widget.initialPage == 1 &&
|
||||
!userService.currentUser.startWithCameraOpen) ||
|
||||
widget.initialPage == 0)) {
|
||||
streamHomeViewPageIndex.add(0);
|
||||
}
|
||||
Future.delayed(const Duration(seconds: 1), () {
|
||||
|
|
|
|||
Loading…
Reference in a new issue