-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
main: Add support for using concrete products when claiming a ticket -> Upgraded ticket use flow to accommodate the selection of menu items explicitly. -> The last selected menu item is cached locally for each ticket (cache cleared on logout). other: Simplified the Product feature file structure. Add improvements to network request handling by adopting a TaskEither type for better composability. Added package Hive for local storage Rename some files and refactor several imports across the codebase Fixed various minor bugs, tightened type constraints, and made use of pattern matching & fpdart types.
- Loading branch information
Showing
94 changed files
with
1,001 additions
and
794 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 34 additions & 25 deletions
59
lib/core/widgets/components/coffee_card.dart → ...core/widgets/components/tickets_card.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 4 additions & 7 deletions
11
...s/components/coffee_card_placeholder.dart → .../components/tickets_card_placeholder.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
lib/features/authentication/domain/usecases/clear_authenticated_user.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
import 'package:coffeecard/features/authentication/data/datasources/authentication_local_data_source.dart'; | ||
import 'package:hive_flutter/hive_flutter.dart'; | ||
|
||
class ClearAuthenticatedUser { | ||
final AuthenticationLocalDataSource dataSource; | ||
|
||
ClearAuthenticatedUser({required this.dataSource}); | ||
|
||
Future<void> call() async { | ||
// Clear last used menu item | ||
final box = await Hive.openBox<int>('lastUsedMenuItemByProductId'); | ||
await box.clear(); | ||
|
||
await dataSource.clearAuthenticatedUser(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 0 additions & 19 deletions
19
lib/features/product/data/datasources/product_remote_data_source.dart
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
lib/features/product/domain/entities/purchasable_products.dart
This file was deleted.
Oops, something went wrong.
21 changes: 0 additions & 21 deletions
21
lib/features/product/domain/usecases/get_all_products.dart
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import 'package:coffeecard/generated/api/coffeecard_api_v2.models.swagger.dart'; | ||
import 'package:equatable/equatable.dart'; | ||
|
||
class MenuItem extends Equatable { | ||
const MenuItem({required this.id, required this.name}); | ||
|
||
factory MenuItem.fromResponse(MenuItemResponse response) => | ||
MenuItem(id: response.id, name: response.name); | ||
|
||
final int id; | ||
final String name; | ||
|
||
@override | ||
List<Object?> get props => [id, name]; | ||
} |
20 changes: 11 additions & 9 deletions
20
lib/features/product/presentation/cubit/product_cubit.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,21 @@ | ||
import 'package:coffeecard/core/errors/failures.dart'; | ||
import 'package:coffeecard/features/product/domain/entities/purchasable_products.dart'; | ||
import 'package:coffeecard/features/product/domain/usecases/get_all_products.dart'; | ||
import 'package:coffeecard/features/product/product_model.dart'; | ||
import 'package:coffeecard/features/product/product_repository.dart'; | ||
import 'package:coffeecard/features/product/purchasable_products.dart'; | ||
import 'package:equatable/equatable.dart'; | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
|
||
part 'product_state.dart'; | ||
|
||
class ProductCubit extends Cubit<ProductState> { | ||
final GetAllProducts getAllProducts; | ||
final ProductRepository productRepository; | ||
|
||
ProductCubit({required this.getAllProducts}) : super(const ProductsLoading()); | ||
ProductCubit({required this.productRepository}) | ||
: super(const ProductsLoading()); | ||
|
||
Future<void> getProducts() async { | ||
emit(const ProductsLoading()); | ||
final result = await getAllProducts(); | ||
emit(result.fold(ProductsError.fromFailure, ProductsLoaded.new)); | ||
} | ||
Future<void> getProducts() => productRepository | ||
.getProducts() | ||
.match(ProductsError.new, ProductsLoaded.new) | ||
.map(emit) | ||
.run(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.