mirror of
https://github.com/Iconica-Development/flutter_shopping.git
synced 2025-05-19 08:53:46 +02:00
feat: add readme
This commit is contained in:
parent
efca65b6be
commit
0e55280116
18 changed files with 122 additions and 56 deletions
82
README.md
Normal file
82
README.md
Normal 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>
|
1
packages/firebase_shopping_repository/CHANGELOG.md
Symbolic link
1
packages/firebase_shopping_repository/CHANGELOG.md
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../../CHANGELOG.md
|
1
packages/firebase_shopping_repository/CONTRIBUTING.md
Symbolic link
1
packages/firebase_shopping_repository/CONTRIBUTING.md
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../../CONTRIBUTING.md
|
1
packages/firebase_shopping_repository/LICENSE
Symbolic link
1
packages/firebase_shopping_repository/LICENSE
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../../LICENSE
|
1
packages/firebase_shopping_repository/README.md
Symbolic link
1
packages/firebase_shopping_repository/README.md
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../../README.md
|
|
@ -5,15 +5,19 @@ import 'package:shopping_repository_interface/shopping_repository_interface.dart
|
||||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||||
|
|
||||||
class FirebaseCategoryRepository implements CategoryRepositoryInterface {
|
class FirebaseCategoryRepository implements CategoryRepositoryInterface {
|
||||||
|
FirebaseCategoryRepository({
|
||||||
|
this.collectionName = 'shopping_category',
|
||||||
|
});
|
||||||
|
|
||||||
|
final String collectionName;
|
||||||
|
|
||||||
final StreamController<List<Category>> _categoryController =
|
final StreamController<List<Category>> _categoryController =
|
||||||
BehaviorSubject<List<Category>>();
|
BehaviorSubject<List<Category>>();
|
||||||
|
|
||||||
final StreamController<List<Category>> _selectedCategoriesController =
|
final StreamController<List<Category>> _selectedCategoriesController =
|
||||||
BehaviorSubject<List<Category>>();
|
BehaviorSubject<List<Category>>();
|
||||||
|
|
||||||
List<Category> _selectedCategories = [];
|
List<Category> _selectedCategories = [];
|
||||||
|
|
||||||
List<Category> _categories = [];
|
List<Category> _categories = [];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void deselectCategory(String? categoryId) {
|
void deselectCategory(String? categoryId) {
|
||||||
_selectedCategories.removeWhere((category) => category.id == categoryId);
|
_selectedCategories.removeWhere((category) => category.id == categoryId);
|
||||||
|
@ -23,7 +27,7 @@ class FirebaseCategoryRepository implements CategoryRepositoryInterface {
|
||||||
@override
|
@override
|
||||||
Stream<List<Category>> getCategories() {
|
Stream<List<Category>> getCategories() {
|
||||||
FirebaseFirestore.instance
|
FirebaseFirestore.instance
|
||||||
.collection('shopping_category')
|
.collection(collectionName)
|
||||||
.snapshots()
|
.snapshots()
|
||||||
.listen((event) {
|
.listen((event) {
|
||||||
List<Category> categories = [];
|
List<Category> categories = [];
|
||||||
|
|
|
@ -6,12 +6,14 @@ import 'package:rxdart/rxdart.dart';
|
||||||
import 'package:shopping_repository_interface/shopping_repository_interface.dart';
|
import 'package:shopping_repository_interface/shopping_repository_interface.dart';
|
||||||
|
|
||||||
class FirebaseProductRepository implements ProductRepositoryInterface {
|
class FirebaseProductRepository implements ProductRepositoryInterface {
|
||||||
/// Shop one product
|
FirebaseProductRepository({
|
||||||
|
this.collectionName = 'shopping_products',
|
||||||
|
});
|
||||||
|
|
||||||
|
final String collectionName;
|
||||||
|
|
||||||
final List<Product> _products = [];
|
final List<Product> _products = [];
|
||||||
|
|
||||||
Product? _selectedProduct;
|
Product? _selectedProduct;
|
||||||
|
|
||||||
final StreamController<List<Product>> _productStream =
|
final StreamController<List<Product>> _productStream =
|
||||||
BehaviorSubject<List<Product>>();
|
BehaviorSubject<List<Product>>();
|
||||||
|
|
||||||
|
@ -22,7 +24,7 @@ class FirebaseProductRepository implements ProductRepositoryInterface {
|
||||||
@override
|
@override
|
||||||
Stream<List<Product>> getProducts(List<Category>? categories, String shopId) {
|
Stream<List<Product>> getProducts(List<Category>? categories, String shopId) {
|
||||||
FirebaseFirestore.instance
|
FirebaseFirestore.instance
|
||||||
.collection('shopping_products')
|
.collection(collectionName)
|
||||||
.doc(shopId)
|
.doc(shopId)
|
||||||
.snapshots()
|
.snapshots()
|
||||||
.listen((event) {
|
.listen((event) {
|
||||||
|
|
|
@ -5,11 +5,14 @@ import 'package:shopping_repository_interface/shopping_repository_interface.dart
|
||||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||||
|
|
||||||
class FirebaseShopRepository implements ShopRepositoryInterface {
|
class FirebaseShopRepository implements ShopRepositoryInterface {
|
||||||
|
FirebaseShopRepository({
|
||||||
|
this.collectionName = 'shopping_shop',
|
||||||
|
});
|
||||||
|
|
||||||
|
final String collectionName;
|
||||||
final StreamController<List<Shop>> _shopController =
|
final StreamController<List<Shop>> _shopController =
|
||||||
BehaviorSubject<List<Shop>>();
|
BehaviorSubject<List<Shop>>();
|
||||||
|
|
||||||
Shop? _selectedShop;
|
Shop? _selectedShop;
|
||||||
|
|
||||||
List<Shop> _shops = [];
|
List<Shop> _shops = [];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -25,7 +28,7 @@ class FirebaseShopRepository implements ShopRepositoryInterface {
|
||||||
@override
|
@override
|
||||||
Stream<List<Shop>> getShops() {
|
Stream<List<Shop>> getShops() {
|
||||||
FirebaseFirestore.instance
|
FirebaseFirestore.instance
|
||||||
.collection('shopping_shop')
|
.collection(collectionName)
|
||||||
.snapshots()
|
.snapshots()
|
||||||
.listen((event) {
|
.listen((event) {
|
||||||
List<Shop> shops = [];
|
List<Shop> shops = [];
|
||||||
|
|
|
@ -6,7 +6,6 @@ import 'package:shopping_repository_interface/shopping_repository_interface.dart
|
||||||
class FirebaseShoppingCartRepository
|
class FirebaseShoppingCartRepository
|
||||||
implements ShoppingCartRepositoryInterface {
|
implements ShoppingCartRepositoryInterface {
|
||||||
var _cart = ShoppingCart(id: "1", products: []);
|
var _cart = ShoppingCart(id: "1", products: []);
|
||||||
|
|
||||||
final StreamController<ShoppingCart> _shoppingCartController =
|
final StreamController<ShoppingCart> _shoppingCartController =
|
||||||
BehaviorSubject<ShoppingCart>();
|
BehaviorSubject<ShoppingCart>();
|
||||||
|
|
||||||
|
|
1
packages/flutter_shopping/CHANGELOG.md
Symbolic link
1
packages/flutter_shopping/CHANGELOG.md
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../../CHANGELOG.md
|
1
packages/flutter_shopping/CONTRIBUTING.md
Symbolic link
1
packages/flutter_shopping/CONTRIBUTING.md
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../../CONTRIBUTING.md
|
1
packages/flutter_shopping/LICENSE
Symbolic link
1
packages/flutter_shopping/LICENSE
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../../LICENSE
|
|
@ -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.
|
|
1
packages/flutter_shopping/README.md
Symbolic link
1
packages/flutter_shopping/README.md
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../../README.md
|
|
@ -13,18 +13,21 @@ class MyApp extends StatelessWidget {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
theme: theme,
|
theme: theme,
|
||||||
home: const Home(),
|
home: const FlutterShopping(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Home extends StatelessWidget {
|
class FlutterShopping extends StatelessWidget {
|
||||||
const Home({super.key});
|
const FlutterShopping({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return const FlutterShoppingNavigatorUserstory(
|
return FlutterShoppingNavigatorUserstory(
|
||||||
options: FlutterShoppingOptions(),
|
options: const FlutterShoppingOptions(),
|
||||||
|
translations: const ShoppingTranslations(),
|
||||||
|
shoppingService: ShoppingService(),
|
||||||
|
initialShopId: "1",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
1
packages/shopping_repository_interface/CHANGELOG.md
Symbolic link
1
packages/shopping_repository_interface/CHANGELOG.md
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../../CHANGELOG.md
|
1
packages/shopping_repository_interface/CONTRIBUTING.md
Symbolic link
1
packages/shopping_repository_interface/CONTRIBUTING.md
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../../CONTRIBUTING.md
|
1
packages/shopping_repository_interface/LICENSE
Symbolic link
1
packages/shopping_repository_interface/LICENSE
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../../LICENSE
|
1
packages/shopping_repository_interface/README.md
Symbolic link
1
packages/shopping_repository_interface/README.md
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../../README.md
|
Loading…
Reference in a new issue