diff --git a/CHANGELOG.md b/CHANGELOG.md index e1805fe..2b52e93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## 1.3.2+11 +* Add a slash to copied URLs +* Expand item when pressing on the card's title in history view + ## 1.3.1+10 * Added gesture detection for tab bar * Disable upload when no files have been attached or upload text input is empty diff --git a/lib/core/util/paste_util.dart b/lib/core/util/paste_util.dart new file mode 100644 index 0000000..eb99037 --- /dev/null +++ b/lib/core/util/paste_util.dart @@ -0,0 +1,6 @@ +class PasteUtil { + /// Generate paste link adding a trailing slash + static String generateLink(String url, String id) { + return '$url/$id/'; + } +} diff --git a/lib/core/viewmodels/upload_model.dart b/lib/core/viewmodels/upload_model.dart index 5495649..5244cb4 100644 --- a/lib/core/viewmodels/upload_model.dart +++ b/lib/core/viewmodels/upload_model.dart @@ -22,6 +22,7 @@ import '../services/file_service.dart'; import '../services/link_service.dart'; import '../services/refresh_service.dart'; import '../util/logger.dart'; +import '../util/paste_util.dart'; import 'base_model.dart'; class UploadModel extends BaseModel { @@ -111,6 +112,22 @@ class UploadModel extends BaseModel { }); } + String generatePasteLinks(Map uploads, String url) { + if (uploads != null && uploads.length > 0) { + var links = ''; + + uploads.forEach((id, isMulti) { + if (isMulti && createMulti || !isMulti && !createMulti) { + links += '${PasteUtil.generateLink(url, id)}\n'; + } + }); + + return links; + } + + return null; + } + void toggleCreateMulti() { setStateView(ViewState.Busy); createMulti = !createMulti; diff --git a/lib/ui/views/history_view.dart b/lib/ui/views/history_view.dart index f94ccab..15f021f 100644 --- a/lib/ui/views/history_view.dart +++ b/lib/ui/views/history_view.dart @@ -8,6 +8,7 @@ import 'package:share/share.dart'; import '../../core/enums/viewstate.dart'; import '../../core/models/session.dart'; import '../../core/util/formatter_util.dart'; +import '../../core/util/paste_util.dart'; import '../../core/viewmodels/history_model.dart'; import '../../ui/widgets/centered_error_row.dart'; import '../shared/app_colors.dart'; @@ -56,7 +57,7 @@ class HistoryView extends StatelessWidget { model.pastes.reversed.forEach((paste) { List widgets = []; - var fullPasteUrl = '$url/${paste.id}'; + var fullPasteUrl = PasteUtil.generateLink(url, paste.id); var openInBrowserButton = _renderOpenInBrowser(model, fullPasteUrl); var dateWidget = ListTile( @@ -144,12 +145,11 @@ class HistoryView extends StatelessWidget { tapHeaderToExpand: true), child: ExpandablePanel( header: InkWell( - onLongPress: () => model.deletePaste(paste.id), child: Text( - paste.id, - style: TextStyle(color: blueColor), - textAlign: TextAlign.left, - )), + paste.id, + style: TextStyle(color: blueColor), + textAlign: TextAlign.left, + )), expanded: Column( mainAxisSize: MainAxisSize.min, children: widgets, diff --git a/lib/ui/views/upload_view.dart b/lib/ui/views/upload_view.dart index 1b5c9fa..d589a25 100644 --- a/lib/ui/views/upload_view.dart +++ b/lib/ui/views/upload_view.dart @@ -119,15 +119,9 @@ class UploadView extends StatelessWidget { ? null : () async { Map items = await model.upload(); + String clipboardContent = model.generatePasteLinks(items, url); - if (items != null) { - var clipboardContent = ''; - items.forEach((id, isMulti) { - if (isMulti && model.createMulti || !isMulti && !model.createMulti) { - clipboardContent += '$url/$id\n'; - } - }); - + if (clipboardContent != null && clipboardContent.isNotEmpty) { FlutterClipboard.copy(clipboardContent).then((value) { final snackBar = SnackBar( action: SnackBarAction( diff --git a/pubspec.yaml b/pubspec.yaml index 18a9c7e..f580298 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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.1+10 +version: 1.3.2+11 environment: sdk: ">=2.7.0 <3.0.0"