Skip to content

Commit

Permalink
Fix server download functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Artx-II committed Feb 28, 2023
1 parent 7326e2a commit b1e119a
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 6 deletions.
14 changes: 11 additions & 3 deletions lib/pages/connect_desktop_page.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
@JS()
library t;

import 'package:js/js.dart';

import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;

import 'package:songtube_link_flutter/internal/styles.dart';

import 'package:http/http.dart' as http;
import 'package:url_launcher/url_launcher.dart';
@JS()
external void download();

class ConnectDesktopPage extends StatefulWidget {
const ConnectDesktopPage({super.key});
Expand All @@ -14,6 +21,7 @@ class ConnectDesktopPage extends StatefulWidget {
}

class _ConnectDesktopPageState extends State<ConnectDesktopPage> {

@override
Widget build(BuildContext context) {
return Column(
Expand Down Expand Up @@ -53,7 +61,7 @@ class _ConnectDesktopPageState extends State<ConnectDesktopPage> {
final windows = assets.firstWhere((element) => element['name'] == 'installer_windows.exe');
// final linux = assets.firstWhere((element) => element['name'] == 'linux_snap_bundle.zip');
final link = windows['browser_download_url'];
launchUrl(Uri.parse(link));
download();
},
child: Container(
padding: const EdgeInsets.only(left: 18, right: 18, top: 8, bottom: 8),
Expand Down
6 changes: 4 additions & 2 deletions lib/pages/connect_device_page.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// ignore: avoid_web_libraries_in_flutter
import 'dart:js' as js;

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

import 'package:songtube_link_flutter/internal/app_connection.dart';
import 'package:songtube_link_flutter/internal/shared_preferences.dart';
import 'package:songtube_link_flutter/internal/styles.dart';
import 'dart:js' as js;

import 'package:songtube_link_flutter/ui/video_details.dart';

class ConnectDevicePage extends StatefulWidget {
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "SongTube Link",
"version": "1.0.0",
"version": "1.0.1",
"description": "Send video links to SongTube App",
"manifest_version": 3,
"author": "Artx",
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ dependencies:
shared_preferences: any
google_fonts: any
url_launcher: ^6.1.10
js: any

# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
Expand Down
4 changes: 4 additions & 0 deletions web/download.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
function download() {
var url = "https://github.com/SongTube/songtube_link_server/releases/download/1.0/installer_windows.exe";
chrome.tabs.create({ url: url });
}
1 change: 1 addition & 0 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@
</head>
<body>
<script src="main.dart.js" type="application/javascript"></script>
<script src="download.js" type="application/javascript"></script>
</body>
</html>

0 comments on commit b1e119a

Please sign in to comment.