-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/data-management' into develop
- Loading branch information
Showing
51 changed files
with
1,242 additions
and
87 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
abstract class NavigationStateService { | ||
void setCurrentPageIndex(int index); | ||
|
||
int get currentPageIndexSync; | ||
|
||
List<NavigationDestination> get destinations; | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:rabenkorb/features/basket/overview/basket_tile.dart'; | ||
import 'package:rabenkorb/models/shopping_basket_view_model.dart'; | ||
import 'package:rabenkorb/services/business/basket_service.dart'; | ||
import 'package:watch_it/watch_it.dart'; | ||
|
||
class BasketList extends StatelessWidget with WatchItMixin { | ||
const BasketList({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final baskets = watchStream((BasketService p0) => p0.baskets, initialValue: []); | ||
final basketList = baskets.data ?? []; | ||
return Expanded( | ||
child: ListView.builder( | ||
prototypeItem: BasketTile( | ||
basket: ShoppingBasketViewModel(-1, "Prototyp"), | ||
), | ||
itemCount: basketList.length, | ||
itemBuilder: (BuildContext context, int index) { | ||
return BasketTile( | ||
basket: basketList[index], | ||
); | ||
}, | ||
), | ||
); | ||
} | ||
} |
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,43 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:rabenkorb/features/basket/overview/basket_list.dart'; | ||
import 'package:rabenkorb/features/core/structural/core_scaffold.dart'; | ||
import 'package:rabenkorb/features/core/structural/drawer/core_drawer.dart'; | ||
import 'package:rabenkorb/generated/l10n.dart'; | ||
import 'package:rabenkorb/services/business/basket_service.dart'; | ||
import 'package:rabenkorb/shared/helper_functions.dart'; | ||
import 'package:watch_it/watch_it.dart'; | ||
|
||
class BasketOverviewPage extends StatelessWidget { | ||
const BasketOverviewPage({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return CoreScaffold( | ||
body: const Center( | ||
child: Padding( | ||
padding: EdgeInsets.all(8.0), | ||
child: Column( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: [BasketList()], | ||
), | ||
), | ||
), | ||
drawer: const CoreDrawer(), | ||
appBar: AppBar( | ||
title: Text(S.of(context).BasketOverview), | ||
), | ||
floatingActionButton: FloatingActionButton( | ||
key: const Key("basket-overview-page-fab"), | ||
onPressed: () async { | ||
await showRenameDialog( | ||
context, | ||
onConfirm: (String? newName, bool _) async { | ||
await di<BasketService>().createShoppingBasket(newName); | ||
}, | ||
); | ||
}, | ||
child: const Icon(Icons.add), | ||
), | ||
); | ||
} | ||
} |
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,68 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:rabenkorb/generated/l10n.dart'; | ||
import 'package:rabenkorb/models/shopping_basket_view_model.dart'; | ||
import 'package:rabenkorb/services/business/basket_service.dart'; | ||
import 'package:rabenkorb/shared/helper_functions.dart'; | ||
import 'package:rabenkorb/shared/widgets/inputs/core_icon_button.dart'; | ||
import 'package:watch_it/watch_it.dart'; | ||
|
||
class BasketTile extends StatelessWidget { | ||
final ShoppingBasketViewModel basket; | ||
|
||
const BasketTile({super.key, required this.basket}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return FutureBuilder<int>( | ||
future: di<BasketService>().countItemsInBasket(basket.id), | ||
initialData: 0, | ||
builder: (BuildContext context, AsyncSnapshot<int> itemsInBasketSnapshot) { | ||
final itemsInBasketCount = itemsInBasketSnapshot.data ?? 0; | ||
return Card( | ||
child: ListTile( | ||
title: Text(basket.name), | ||
subtitle: Text("${S.of(context).Items}: $itemsInBasketCount"), | ||
trailing: Row( | ||
mainAxisAlignment: MainAxisAlignment.end, | ||
mainAxisSize: MainAxisSize.min, | ||
children: [ | ||
CoreIconButton( | ||
icon: const Icon(Icons.edit), | ||
onPressed: () async { | ||
await showRenameDialog( | ||
context, | ||
initialName: basket.name, | ||
onConfirm: (String? newName, bool nameChanged) async { | ||
if (!nameChanged || newName == null) { | ||
return; | ||
} | ||
await di<BasketService>().updateShoppingBasket(basket.id, newName); | ||
}, | ||
); | ||
}, | ||
), | ||
CoreIconButton( | ||
icon: const Icon( | ||
Icons.delete_forever, | ||
color: Colors.red, | ||
), | ||
onPressed: () async { | ||
await doWithConfirmation( | ||
context, | ||
text: S.of(context).ConfirmDeleteBasket, | ||
title: S.of(context).Confirm, | ||
onConfirm: () async { | ||
await di<BasketService>().deleteShoppingBasketById(basket.id); | ||
di<BasketService>().setFirstShoppingBasketActive(); | ||
}, | ||
); | ||
}, | ||
) | ||
], | ||
), | ||
), | ||
); | ||
}, | ||
); | ||
} | ||
} |
Oops, something went wrong.