Skip to content

Commit

Permalink
Fix shorebird to show notification
Browse files Browse the repository at this point in the history
  • Loading branch information
vyPal committed Sep 7, 2023
1 parent 2ba48c6 commit c946f7c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 30 deletions.
32 changes: 3 additions & 29 deletions lib/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import 'package:package_info/package_info.dart';
import 'package:restart_app/restart_app.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:shorebird_code_push/shorebird_code_push_web.dart';
import 'package:shorebird_code_push/shorebird_code_push.dart';
import 'package:url_launcher/url_launcher.dart';

class HomePage extends StatefulWidget {
Expand Down Expand Up @@ -189,20 +189,14 @@ class HomePageState extends State<HomePage> {
});

if (isUpdateAvailable) {
_showUpdateAvailableBanner();
} else {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('No update available'),
),
);
_downloadUpdate();
}
}

void _showDownloadingBanner() {
ScaffoldMessenger.of(context).showMaterialBanner(
const MaterialBanner(
content: Text('Downloading...'),
content: Text('Downloading patch...'),
actions: [
SizedBox(
height: 14,
Expand All @@ -216,26 +210,6 @@ class HomePageState extends State<HomePage> {
);
}

void _showUpdateAvailableBanner() {
ScaffoldMessenger.of(context).showMaterialBanner(
MaterialBanner(
content: const Text('Update available'),
actions: [
TextButton(
onPressed: () async {
ScaffoldMessenger.of(context).hideCurrentMaterialBanner();
await _downloadUpdate();

if (!mounted) return;
ScaffoldMessenger.of(context).hideCurrentMaterialBanner();
},
child: const Text('Download'),
),
],
),
);
}

void _showRestartBanner() {
ScaffoldMessenger.of(context).showMaterialBanner(
const MaterialBanner(
Expand Down
2 changes: 1 addition & 1 deletion shorebird.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ app_id: 0f4dc1a8-0c38-409f-838c-9bca97783f4a
# If auto_update: false, you will need to use package:shorebird_code_push to trigger updates.
# https://pub.dev/packages/shorebird_code_push
# Uncomment the following line to disable automatic updates.
auto_update: true
auto_update: false

0 comments on commit c946f7c

Please sign in to comment.