Skip to content

Commit

Permalink
Add url_launcher on song detail screen
Browse files Browse the repository at this point in the history
  • Loading branch information
up2code committed Mar 18, 2024
1 parent d91eb41 commit 41b322a
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:vocadb_app/src/constants/app_sizes.dart';
import 'package:vocadb_app/src/features/songs/domain/song.dart';
import 'package:vocadb_app/src/features/songs/presentation/song_detail_screen/widgets/song_detail_like_button.dart';
import 'package:vocadb_app/src/utils/url_launcher.dart';

class SongDetailButtonBar extends StatelessWidget {
const SongDetailButtonBar(
Expand Down Expand Up @@ -52,19 +54,25 @@ class SongDetailButtonBar extends StatelessWidget {
],
),
),
TextButton(
key: infoBtnKey,
onPressed: () => {},
style: ButtonStyle(
foregroundColor: MaterialStateProperty.all<Color>(Colors.white),
),
child: Column(
children: const [
Icon(Icons.info),
gapH4,
Text('Info'),
],
),
Consumer(
builder: (context, ref, _) {
return TextButton(
key: infoBtnKey,
onPressed: () {
ref.read(urlLauncherProvider).launchMoreInfo('/S/${song.id}');
},
style: ButtonStyle(
foregroundColor: MaterialStateProperty.all<Color>(Colors.white),
),
child: Column(
children: const [
Icon(Icons.info),
gapH4,
Text('Info'),
],
),
);
},
),
],
);
Expand Down
20 changes: 20 additions & 0 deletions lib/src/utils/url_launcher.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:url_launcher/url_launcher_string.dart';
import 'package:vocadb_app/flavor_config.dart';

class UrlLauncher {

final String host;

UrlLauncher(this.host);

launchMoreInfo(String path) {
launchUrlString('https://${host}${path}');
}
}


final urlLauncherProvider = Provider<UrlLauncher>((ref) {
final flavorConfig = ref.watch(flavorConfigProvider);
return UrlLauncher(flavorConfig.apiAuthority);
});
6 changes: 3 additions & 3 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -958,10 +958,10 @@ packages:
dependency: "direct main"
description:
name: url_launcher
sha256: "3c92b0efb5e9dcb8f846aefabf9f0f739f91682ed486b991ceda51c288e60896"
sha256: "47e208a6711459d813ba18af120d9663c20bdf6985d6ad39fe165d2538378d27"
url: "https://pub.dev"
source: hosted
version: "6.1.7"
version: "6.1.14"
url_launcher_android:
dependency: transitive
description:
Expand Down Expand Up @@ -1108,4 +1108,4 @@ packages:
version: "8.1.2"
sdks:
dart: ">=3.0.0 <4.0.0"
flutter: ">=3.3.0"
flutter: ">=3.10.0"
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ dependencies:
rxdart: 0.27.7
share_plus: 6.3.0
font_awesome_flutter: 10.3.0
url_launcher: 6.1.7
url_launcher: 6.1.14
intl: 0.18.0
collection: 1.17.1
flutter_markdown: 0.6.13
Expand Down

0 comments on commit 41b322a

Please sign in to comment.