Automatically switch to initial tab when coming from the share menu
This commit is contained in:
parent
c0a2e8d569
commit
9b440ee63c
5 changed files with 43 additions and 12 deletions
|
@ -1,5 +1,8 @@
|
|||
# CHANGELOG
|
||||
|
||||
## 1.3.3+12 - UNRELEASED
|
||||
* Automatically switch to initial tab when coming from the share menu
|
||||
|
||||
## 1.3.2+11
|
||||
* Add a slash to copied URLs
|
||||
* Expand item when pressing on the card's title in history view
|
||||
|
|
|
@ -1 +1 @@
|
|||
enum SwipeEvent { Left, Right }
|
||||
enum SwipeEvent { Start, Left, Right, End }
|
||||
|
|
|
@ -12,6 +12,7 @@ import 'package:receive_sharing_intent/receive_sharing_intent.dart';
|
|||
import '../../locator.dart';
|
||||
import '../enums/error_code.dart';
|
||||
import '../enums/refresh_event.dart';
|
||||
import '../enums/swipe_event.dart';
|
||||
import '../enums/viewstate.dart';
|
||||
import '../error/rest_service_exception.dart';
|
||||
import '../error/service_exception.dart';
|
||||
|
@ -21,6 +22,7 @@ import '../models/rest/uploaded_response.dart';
|
|||
import '../services/file_service.dart';
|
||||
import '../services/link_service.dart';
|
||||
import '../services/refresh_service.dart';
|
||||
import '../services/swipe_service.dart';
|
||||
import '../util/logger.dart';
|
||||
import '../util/paste_util.dart';
|
||||
import 'base_model.dart';
|
||||
|
@ -30,6 +32,7 @@ class UploadModel extends BaseModel {
|
|||
final FileService _fileService = locator<FileService>();
|
||||
final LinkService _linkService = locator<LinkService>();
|
||||
final RefreshService _refreshService = locator<RefreshService>();
|
||||
final SwipeService _swipeService = locator<SwipeService>();
|
||||
|
||||
TextEditingController _pasteTextController = TextEditingController();
|
||||
bool pasteTextTouched = false;
|
||||
|
@ -64,12 +67,12 @@ class UploadModel extends BaseModel {
|
|||
});
|
||||
}).toList();
|
||||
setStateView(ViewState.Idle);
|
||||
if (paths.isNotEmpty && paths.length > 0) {
|
||||
_swipeService.addEvent(SwipeEvent.Start);
|
||||
}
|
||||
}
|
||||
}, onError: (err) {
|
||||
setStateView(ViewState.Busy);
|
||||
errorMessage = translate('upload.retrieval_intent');
|
||||
_logger.e('Error while retrieving shared data: $err');
|
||||
setStateView(ViewState.Idle);
|
||||
_errorIntentHandle(err);
|
||||
});
|
||||
|
||||
// For sharing images coming from outside the app while the app is closed
|
||||
|
@ -85,7 +88,12 @@ class UploadModel extends BaseModel {
|
|||
});
|
||||
}).toList();
|
||||
setStateView(ViewState.Idle);
|
||||
if (paths.isNotEmpty && paths.length > 0) {
|
||||
_swipeService.addEvent(SwipeEvent.Start);
|
||||
}
|
||||
}
|
||||
}, onError: (err) {
|
||||
_errorIntentHandle(err);
|
||||
});
|
||||
|
||||
// For sharing or opening urls/text coming from outside the app while the app is in the memory
|
||||
|
@ -94,12 +102,10 @@ class UploadModel extends BaseModel {
|
|||
setStateView(ViewState.Busy);
|
||||
pasteTextController.text = value;
|
||||
setStateView(ViewState.Idle);
|
||||
_swipeService.addEvent(SwipeEvent.Start);
|
||||
}
|
||||
}, onError: (err) {
|
||||
setStateView(ViewState.Busy);
|
||||
errorMessage = translate('upload.retrieval_intent');
|
||||
_logger.e('Error while retrieving shared data: $err');
|
||||
setStateView(ViewState.Idle);
|
||||
_errorIntentHandle(err);
|
||||
});
|
||||
|
||||
// For sharing or opening urls/text coming from outside the app while the app is closed
|
||||
|
@ -108,10 +114,24 @@ class UploadModel extends BaseModel {
|
|||
setStateView(ViewState.Busy);
|
||||
pasteTextController.text = value;
|
||||
setStateView(ViewState.Idle);
|
||||
if (paths.isNotEmpty && paths.length > 0) {
|
||||
_swipeService.addEvent(SwipeEvent.Start);
|
||||
}
|
||||
}
|
||||
}, onError: (err) {
|
||||
_errorIntentHandle(err);
|
||||
});
|
||||
}
|
||||
|
||||
void _errorIntentHandle(err) {
|
||||
setStateView(ViewState.Busy);
|
||||
errorMessage = translate('upload.retrieval_intent');
|
||||
_logger.e('Error while retrieving shared data: $err');
|
||||
setStateView(ViewState.Idle);
|
||||
|
||||
_swipeService.addEvent(SwipeEvent.Start);
|
||||
}
|
||||
|
||||
String generatePasteLinks(Map<String, bool> uploads, String url) {
|
||||
if (uploads != null && uploads.length > 0) {
|
||||
var links = '';
|
||||
|
|
|
@ -52,7 +52,7 @@ class AuthenticatedTabBarState extends State<AuthenticatedTabBarView> with Singl
|
|||
});
|
||||
|
||||
_swipeEventSubscription = _swipeService.swipeEventController.stream.listen((SwipeEvent event) {
|
||||
_logger.d('Received an swipe event for the authenticated tab bar: $event');
|
||||
_logger.d('Received a swipe event for the authenticated tab bar: $event');
|
||||
|
||||
int targetIndex = _currentTabIndex;
|
||||
if (SwipeEvent.Left == event) {
|
||||
|
@ -63,7 +63,15 @@ class AuthenticatedTabBarState extends State<AuthenticatedTabBarView> with Singl
|
|||
targetIndex = max(_currentTabIndex - 1, 0);
|
||||
}
|
||||
|
||||
_logger.d("Changing to tab '$targetIndex' because of a swipe event");
|
||||
if (SwipeEvent.Start == event) {
|
||||
targetIndex = 0;
|
||||
}
|
||||
|
||||
if (SwipeEvent.End == event) {
|
||||
targetIndex = _tabPages.length - 1;
|
||||
}
|
||||
|
||||
_logger.d("Changing to tab '$targetIndex' because of a swipe event '$event'");
|
||||
_tabController.animateTo(targetIndex);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ description: A mobile client for FileBin.
|
|||
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
|
||||
# Read more about iOS versioning at
|
||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||
version: 1.3.2+11
|
||||
version: 1.3.3+12
|
||||
|
||||
environment:
|
||||
sdk: ">=2.7.0 <3.0.0"
|
||||
|
|
Loading…
Reference in a new issue