This commit is contained in:
Freek van de Ven 2025-05-11 15:27:34 +02:00 committed by GitHub
commit a464738756
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 76 additions and 14 deletions

View file

@ -35,6 +35,15 @@ There is also a function for pushing the availability screen to the navigation s
openAvailabilitiesForUser(context, "userIdOfTheUser", AvailabilityOptions()); openAvailabilitiesForUser(context, "userIdOfTheUser", AvailabilityOptions());
``` ```
You can also use the AvailabilityEntryWidget to show a button with an icon and some styling options that starts the userstory:
```dart
AvailabilityEntryWidget(
userId: "userIdOfTheUser",
options: AvailabilityOptions(),
),
```
## Issues ## Issues
Please file any issues, bugs or feature request as an issue on our [GitHub](https://github.com/Iconica-Development/flutter_availability) page. Commercial support is available if you need help with integration with your app or services. You can contact us at [support@iconica.nl](mailto:support@iconica.nl). Please file any issues, bugs or feature request as an issue on our [GitHub](https://github.com/Iconica-Development/flutter_availability) page. Commercial support is available if you need help with integration with your app or services. You can contact us at [support@iconica.nl](mailto:support@iconica.nl).

View file

@ -29,10 +29,7 @@ class App extends StatelessWidget {
], ],
theme: ThemeData.light(), theme: ThemeData.light(),
darkTheme: ThemeData.dark(), darkTheme: ThemeData.dark(),
home: AvailabilityUserStory( home: const Home(),
userId: "",
options: AvailabilityOptions(),
),
); );
} }
@ -40,16 +37,10 @@ class Home extends StatelessWidget {
const Home({super.key}); const Home({super.key});
@override @override
Widget build(BuildContext context) => Scaffold( Widget build(BuildContext context) => const Scaffold(
body: const Center( body: Center(
child: Text("Hello World"), child: Text("Start the user story by tapping the button below"),
),
floatingActionButton: FloatingActionButton(
onPressed: () async {
debugPrint("starting availability user story");
await openAvailabilitiesForUser(context, "", null);
debugPrint("finishing availability user story");
},
), ),
floatingActionButton: AvailabilityEntryWidget(),
); );
} }

View file

@ -3,6 +3,7 @@ library flutter_availability;
export "package:flutter_availability_data_interface/flutter_availability_data_interface.dart"; export "package:flutter_availability_data_interface/flutter_availability_data_interface.dart";
export "src/availability_entry_widget.dart";
export "src/config/availability_options.dart"; export "src/config/availability_options.dart";
export "src/config/availability_translations.dart"; export "src/config/availability_translations.dart";
export "src/service/errors.dart"; export "src/service/errors.dart";

View file

@ -0,0 +1,61 @@
import "package:flutter/material.dart";
import "package:flutter_availability/src/config/availability_options.dart";
import "package:flutter_availability/src/userstories.dart";
/// A widget representing an entry point for the Availability user story.
class AvailabilityEntryWidget extends StatelessWidget {
/// Constructs a [AvailabilityEntryWidget].
const AvailabilityEntryWidget({
this.options,
this.onTap,
this.userId = "",
this.widgetSize = 75,
this.backgroundColor = Colors.grey,
this.icon = Icons.event_available_outlined,
this.iconColor = Colors.black,
super.key,
});
/// The user id for which the availability should be displayed.
final String userId;
/// Options to configure the availability user story.
final AvailabilityOptions? options;
/// Background color of the widget.
final Color backgroundColor;
/// Size of the widget.
final double widgetSize;
/// Callback function triggered when the widget is tapped. If this is not null
/// the callback will be triggered otherwise the availability user story will
/// be opened
final VoidCallback? onTap;
/// Icon to be displayed.
final IconData icon;
/// Color of the icon.
final Color iconColor;
@override
Widget build(BuildContext context) => InkWell(
onTap: () async {
if (onTap != null) {
onTap?.call();
} else {
await openAvailabilitiesForUser(context, "", options);
}
},
highlightColor: Colors.transparent,
hoverColor: Colors.transparent,
child: Container(
width: widgetSize,
height: widgetSize,
decoration:
BoxDecoration(shape: BoxShape.circle, color: backgroundColor),
child: Icon(icon, color: iconColor, size: widgetSize / 1.5),
),
);
}