Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/upgrade announcer widget #464

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

twklessor
Copy link

@twklessor twklessor commented Oct 14, 2024

Add UpgradeAnnouncer widget. This widget should be used at the top of the widget tree just below MaterialApp. Uses a MaterialBanner with showMaterialBanner. We utilize the scaffoldMessengerKey to make this possible.

This has a distinct advantage over the UpgradeAlert as the MaterialBanner is shown globally; also during navigation.

This is the MaterialBanner shown globally;

image

When the MaterialBanner is tapped a bottom sheet is shown with the appropriate release notes;

screenshot-1

The UpgradeAnnouncer also supports what is called enforceUpgrade which uses the Upgrader.minAppVersion to enforce an update if the current version is lower. This presents a dialog that cannot be dismissed; similar to what the UpgradeAlert supports;
image

Simple example of usage;

      MaterialApp(
        scaffoldMessengerKey: rootScaffoldMessengerKey,
        home: UpgradeAnnouncer(
          scaffoldMessengerKey: rootScaffoldMessengerKey,
          child: Scaffold(
            body: const Placeholder(),
            appBar: AppBar(title: const Text('Upgrader test')),
          ),
        ),
      );

Example with customizable icons, text styles and colors;

      const backgroundColor = Colors.red;
      const infoIcon = Icons.add;
      const infoIconColor = Colors.blue;
      const downloadIcon = Icons.abc;
      const downloadIconColor = Colors.yellow;
      const titleTextStyle = TextStyle(color: Colors.amber, fontSize: 20);
      const bottomSheetTitleTextStyle =
          TextStyle(color: Colors.orange, fontSize: 25);
      const bottomSheetReleaseNotesTextStyle =
          TextStyle(color: Colors.purple, fontSize: 30);
      const bottomSheetBackgroundColor = Colors.teal;

      MaterialApp(
        scaffoldMessengerKey: rootScaffoldMessengerKey,
        home: UpgradeAnnouncer(
          scaffoldMessengerKey: rootScaffoldMessengerKey,
          backgroundColor: backgroundColor,
          infoIcon: infoIcon,
          infoIconColor: infoIconColor,
          downloadIcon: downloadIcon,
          downloadIconColor: downloadIconColor,
          titleTextStyle: titleTextStyle,
          bottomSheetTitleTextStyle: bottomSheetTitleTextStyle,
          bottomSheetReleaseNotesTextStyle: bottomSheetReleaseNotesTextStyle,
          bottomSheetBackgroundColor: bottomSheetBackgroundColor,
          child: Scaffold(
            body: const Placeholder(),
            appBar: AppBar(title: const Text('Upgrader test')),
          ),
        ),
      );

This new UpgradeAnnouncer widget is fully backed by a test.

… the widget tree. Uses a MaterialBanner with showMaterialBanner.
… the widget tree. Uses a MaterialBanner with showMaterialBanner.

Added widget tests.
… the widget tree. Uses a MaterialBanner with showMaterialBanner.
When set to true this will enforce an upgrade based on the Upgrader.minAppVersion version.
@twklessor
Copy link
Author

twklessor commented Nov 15, 2024

@larryaasen We are considering making a fork of this package with our additions if it doesn't "fit the cake" but frankly we want to avoid that. We want to give back what you've already given us. We are very open to any feedback, changes or improvements. The UpgradeAnnouncer does have some overlapping features compared to the UpgradeAlert but they do compliment each other.

We already use the UpgradeAnnouncer in 2 production apps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant