feat: add readme

This commit is contained in:
mike doornenbal 2024-10-21 11:40:25 +02:00
parent efca65b6be
commit 0e55280116
18 changed files with 122 additions and 56 deletions

82
README.md Normal file
View file

@ -0,0 +1,82 @@
# Flutter Shopping
Flutter Shopping is a package that allows you to create a shopping experience in your Flutter app.
By default, it uses a `ShoppingService` with a local implementation ,it provides a simple shopping
experience with a list of products and a shopping cart. You can implement your own `ShoppingService` by overriding the `shopRepository`, `cartRepository`, `categoryRepository` and `orderRepository` properties.
## Setup
To use this package, add flutter_shopping as a dependency in your pubspec.yaml file:
```
flutter_chat:
git:
url: https://github.com/Iconica-Development/flutter_shopping
path: packages/flutter_shopping
```
If you are going to use Firebase as the back-end of flutter_shopping, you should also add the following package as a dependency to your pubspec.yaml file:
```
firebase_shopping_repository:
git:
url: https://github.com/Iconica-Development/flutter_shopping
path: packages/firebase_shopping_repository
```
Create a Firebase project for your application and add firebase firestore and storage.
make sure you are authenticated using the `Firebase_auth` package or adjust your firebase rules, otherwise you won't be able to retreive data.
Also make sure you have the corresponding collections in your firebase project as defined in the `FirebaseRepositories`, you can override the
default paths as you wish:
``` dart
FirebaseCategoryRepository({
this.collectionName = 'shopping_category',
});
FirebaseCartRepository({
this.collectionName = 'shopping_cart',
});
FirebaseOrderRepository({
this.collectionName = 'shopping_order',
});
```
Also the structure of your data should be equal to our predefined models.
## How to use
To use this package, add the following widget `FlutterShoppingNavigatorUserstory` to your widget tree:
``` dart
class FlutterShopping extends StatelessWidget {
const FlutterShopping({super.key});
@override
Widget build(BuildContext context) {
return FlutterShoppingNavigatorUserstory(
options: const FlutterShoppingOptions(),
translations: const ShoppingTranslations(),
shoppingService: ShoppingService(),
initialShopId: "1",
);
}
}
```
All of the properties are optional.
## Issues
Please file any issues, bugs or feature request as an issue on our [GitHub](https://github.com/Iconica-Development/flutter_shopping/pulls) 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).
## Want to contribute
If you would like to contribute to the plugin (e.g. by improving the documentation, solving a bug or adding a cool new feature), please carefully review our [contribution guide](./CONTRIBUTING.md) and send us your [pull request](https://github.com/Iconica-Development/flutter_shopping/pulls).
## Author
This `flutter_shopping` for Flutter is developed by [Iconica](https://iconica.nl). You can contact us at <support@iconica.nl>

View file

@ -0,0 +1 @@
../../CHANGELOG.md

View file

@ -0,0 +1 @@
../../CONTRIBUTING.md

View file

@ -0,0 +1 @@
../../LICENSE

View file

@ -0,0 +1 @@
../../README.md

View file

@ -5,15 +5,19 @@ import 'package:shopping_repository_interface/shopping_repository_interface.dart
import 'package:cloud_firestore/cloud_firestore.dart';
class FirebaseCategoryRepository implements CategoryRepositoryInterface {
FirebaseCategoryRepository({
this.collectionName = 'shopping_category',
});
final String collectionName;
final StreamController<List<Category>> _categoryController =
BehaviorSubject<List<Category>>();
final StreamController<List<Category>> _selectedCategoriesController =
BehaviorSubject<List<Category>>();
List<Category> _selectedCategories = [];
List<Category> _categories = [];
@override
void deselectCategory(String? categoryId) {
_selectedCategories.removeWhere((category) => category.id == categoryId);
@ -23,7 +27,7 @@ class FirebaseCategoryRepository implements CategoryRepositoryInterface {
@override
Stream<List<Category>> getCategories() {
FirebaseFirestore.instance
.collection('shopping_category')
.collection(collectionName)
.snapshots()
.listen((event) {
List<Category> categories = [];

View file

@ -6,12 +6,14 @@ import 'package:rxdart/rxdart.dart';
import 'package:shopping_repository_interface/shopping_repository_interface.dart';
class FirebaseProductRepository implements ProductRepositoryInterface {
/// Shop one product
FirebaseProductRepository({
this.collectionName = 'shopping_products',
});
final String collectionName;
final List<Product> _products = [];
Product? _selectedProduct;
final StreamController<List<Product>> _productStream =
BehaviorSubject<List<Product>>();
@ -22,7 +24,7 @@ class FirebaseProductRepository implements ProductRepositoryInterface {
@override
Stream<List<Product>> getProducts(List<Category>? categories, String shopId) {
FirebaseFirestore.instance
.collection('shopping_products')
.collection(collectionName)
.doc(shopId)
.snapshots()
.listen((event) {

View file

@ -5,11 +5,14 @@ import 'package:shopping_repository_interface/shopping_repository_interface.dart
import 'package:cloud_firestore/cloud_firestore.dart';
class FirebaseShopRepository implements ShopRepositoryInterface {
FirebaseShopRepository({
this.collectionName = 'shopping_shop',
});
final String collectionName;
final StreamController<List<Shop>> _shopController =
BehaviorSubject<List<Shop>>();
Shop? _selectedShop;
List<Shop> _shops = [];
@override
@ -25,7 +28,7 @@ class FirebaseShopRepository implements ShopRepositoryInterface {
@override
Stream<List<Shop>> getShops() {
FirebaseFirestore.instance
.collection('shopping_shop')
.collection(collectionName)
.snapshots()
.listen((event) {
List<Shop> shops = [];

View file

@ -6,7 +6,6 @@ import 'package:shopping_repository_interface/shopping_repository_interface.dart
class FirebaseShoppingCartRepository
implements ShoppingCartRepositoryInterface {
var _cart = ShoppingCart(id: "1", products: []);
final StreamController<ShoppingCart> _shoppingCartController =
BehaviorSubject<ShoppingCart>();

View file

@ -0,0 +1 @@
../../CHANGELOG.md

View file

@ -0,0 +1 @@
../../CONTRIBUTING.md

View file

@ -0,0 +1 @@
../../LICENSE

View file

@ -1,39 +0,0 @@
<!--
This README describes the package. If you publish this package to pub.dev,
this README's contents appear on the landing page for your package.
For information about how to write a good package README, see the guide for
[writing package pages](https://dart.dev/tools/pub/writing-package-pages).
For general information about developing packages, see the Dart guide for
[creating packages](https://dart.dev/guides/libraries/create-packages)
and the Flutter guide for
[developing packages and plugins](https://flutter.dev/to/develop-packages).
-->
TODO: Put a short description of the package here that helps potential users
know whether this package might be useful for them.
## Features
TODO: List what your package can do. Maybe include images, gifs, or videos.
## Getting started
TODO: List prerequisites and provide or point to information on how to
start using the package.
## Usage
TODO: Include short and useful examples for package users. Add longer examples
to `/example` folder.
```dart
const like = 'sample';
```
## Additional information
TODO: Tell users more about the package: where to find more information, how to
contribute to the package, how to file issues, what response they can expect
from the package authors, and more.

View file

@ -0,0 +1 @@
../../README.md

View file

@ -13,18 +13,21 @@ class MyApp extends StatelessWidget {
Widget build(BuildContext context) {
return MaterialApp(
theme: theme,
home: const Home(),
home: const FlutterShopping(),
);
}
}
class Home extends StatelessWidget {
const Home({super.key});
class FlutterShopping extends StatelessWidget {
const FlutterShopping({super.key});
@override
Widget build(BuildContext context) {
return const FlutterShoppingNavigatorUserstory(
options: FlutterShoppingOptions(),
return FlutterShoppingNavigatorUserstory(
options: const FlutterShoppingOptions(),
translations: const ShoppingTranslations(),
shoppingService: ShoppingService(),
initialShopId: "1",
);
}
}

View file

@ -0,0 +1 @@
../../CHANGELOG.md

View file

@ -0,0 +1 @@
../../CONTRIBUTING.md

View file

@ -0,0 +1 @@
../../LICENSE

View file

@ -0,0 +1 @@
../../README.md