feat: Added proper package references

This commit is contained in:
Jacques 2023-11-29 11:13:17 +01:00
parent 2fb48ab992
commit 36125f4174
7 changed files with 23 additions and 13 deletions

View file

@ -2,26 +2,27 @@
Monorepo for the Flutter introduction package. Including the following packages: Monorepo for the Flutter introduction package. Including the following packages:
- Flutter Introduction - Flutter Introduction
Main packge for Flutter Introduction. Main packge for Flutter Introduction including an example.
- Flutter Introduction Firebase - Flutter Introduction Firebase
Package to provide content from firebase. Package to provide content from firebase.
- Flutter Introduction Interface - Flutter Introduction Interface
Interface regarding data for the Introduction widget, like wether to show the introduction or not.
- Flutter Introduction Service - Flutter Introduction Service
Service to handle actions done in the Introduction widget.
- Flutter Introduction Shared Preferences - Flutter Introduction Shared Preferences
Implementation of the interface with the use of shared preferences.
- Flutter Introduction Widget - Flutter Introduction Widget
The actual widget showing the Introduction widget.
## Setup
## How to use ## How to use
The simple way to use this package is by using the flutter_introduction package. An example is included if needed.
If needed a custom implementation can be made on the interface if the shared preferences doesn't suffice.
## Issues ## Issues

View file

@ -69,7 +69,7 @@ class _MyHomePageState extends State<MyHomePage> {
buttonMode: IntroductionScreenButtonMode.text, buttonMode: IntroductionScreenButtonMode.text,
indicatorMode: IndicatorMode.dash, indicatorMode: IndicatorMode.dash,
skippable: true, skippable: true,
buttonBuilder: (context, onPressed, child) => buttonBuilder: (context, onPressed, child, type) =>
ElevatedButton(onPressed: onPressed, child: child), ElevatedButton(onPressed: onPressed, child: child),
), ),
service: service, service: service,

View file

@ -17,9 +17,10 @@ dependencies:
flutter_introduction: flutter_introduction:
path: ../ path: ../
flutter_introduction_shared_preferences: flutter_introduction_shared_preferences:
git: git:
url: https://github.com/Iconica-Development/flutter_introduction_shared_preferences.git url: https://github.com/Iconica-Development/flutter_introduction
ref: 1.0.0 ref: 2.0.0
path: packages/flutter_introduction_shared_preferences
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:

View file

@ -44,6 +44,11 @@ class FirebaseIntroductionService {
}).toList(); }).toList();
} }
Future<bool> introductionIsDisabled() async {
var document = await _documentRef.get();
return document.data()!['disabled'] as bool? ?? false;
}
Future<bool> shouldAlwaysShowIntroduction() async { Future<bool> shouldAlwaysShowIntroduction() async {
var document = await _documentRef.get(); var document = await _documentRef.get();
return document.data()!['always_show'] as bool? ?? false; return document.data()!['always_show'] as bool? ?? false;

View file

@ -97,10 +97,12 @@ class _IntroductionState extends State<IntroductionFirebase> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
Future<bool> shouldShow() async => Future<bool> shouldShow() async =>
await _service.shouldShow() || !await _firebaseService.introductionIsDisabled() &&
await _firebaseService.shouldAlwaysShowIntroduction(); (await _service.shouldShow() ||
await _firebaseService.shouldAlwaysShowIntroduction());
var languageCode = widget.languageCodeOverride ?? var languageCode = widget.languageCodeOverride ??
Localizations.localeOf(context).languageCode; Localizations.localeOf(context).languageCode;
return FutureBuilder( return FutureBuilder(
future: shouldShow(), future: shouldShow(),
builder: (context, snapshot) { builder: (context, snapshot) {

View file

@ -15,7 +15,7 @@ dependencies:
url: https://github.com/Iconica-Development/flutter_introduction url: https://github.com/Iconica-Development/flutter_introduction
ref: 2.0.0 ref: 2.0.0
path: packages/flutter_introduction_interface path: packages/flutter_introduction_interface
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter

View file

@ -1,4 +1,5 @@
name: flutter_introduction_workspace name: flutter_introduction_workspace
version: 2.0.0
environment: environment:
sdk: '>=3.1.0 <4.0.0' sdk: '>=3.1.0 <4.0.0'