Skip to content

Commit

Permalink
fix copy text on mobile devices
Browse files Browse the repository at this point in the history
  • Loading branch information
LiquidatorCoder committed Nov 26, 2021
1 parent c191719 commit 120b006
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/pages/home_page.dart
Expand Up @@ -13,6 +13,7 @@ import 'package:odin/painters/tooltip_painter.dart';
import 'package:odin/providers/file_notifier.dart';
import 'package:odin/services/locator.dart';
import 'package:odin/services/preferences_service.dart';
import 'package:odin/services/shortener_service.dart';
import 'package:odin/services/toast_service.dart';
import 'package:odin/widgets/window_top_bar.dart';
import 'package:open_file/open_file.dart';
Expand Down Expand Up @@ -74,6 +75,7 @@ class _HomePageState extends State<HomePage>
@override
Widget build(BuildContext context) {
final _fileNotifier = context.watch<FileNotifier>();
final _shortenerService = locator<ShortenerService>();
return Scaffold(
backgroundColor: const Color(0xFF7D5DEC),
body: Container(
Expand Down Expand Up @@ -352,7 +354,9 @@ class _HomePageState extends State<HomePage>
onTap: () => FlutterClipboard.copy(_fileNotifier
.fileLink !=
null
? "Some files were shared with you.\nTo access them, download Odin from https://shrtco.de/odin and enter this unique token - ${_fileNotifier.fileLink}"
? Platform.isAndroid || Platform.isIOS
? "Some files were shared with you.\nTo access them, visit ${_fileNotifier.fileLink} from your mobile device. To access them on your PC, download Odin from https://shrtco.de/odin and enter this unique token - ${_shortenerService.token}"
: "Some files were shared with you.\nTo access them, download Odin from https://shrtco.de/odin and enter this unique token - ${_fileNotifier.fileLink}"
: '')
.then((value) => _toast.showToast(
Platform.isIOS || Platform.isMacOS
Expand Down
4 changes: 3 additions & 1 deletion lib/services/shortener_service.dart
Expand Up @@ -7,6 +7,7 @@ import 'package:odin/services/logger.dart';
import 'package:odin/services/zip_service.dart';

class ShortenerService {
String token = "";
final _zipService = locator<ZipService>();
final _dio = Dio(BaseOptions(
baseUrl: 'https://api.shrtco.de/v2/',
Expand Down Expand Up @@ -63,7 +64,8 @@ class ShortenerService {
final Response? response = await post(uri: 'shorten?url=$url');
if (response != null) {
final shortLink = response.data["result"]["full_short_link"];
return shortLink.replaceAll("https://shrtco.de/", "") + password;
token = shortLink.replaceAll("https://shrtco.de/", "") + password;
return token;
} else {
return null;
}
Expand Down

0 comments on commit 120b006

Please sign in to comment.