diff --git a/client/cashcompass/lib/screens/add_category/add_category_screen.dart b/client/cashcompass/lib/screens/add_category/add_category_screen.dart new file mode 100644 index 0000000..0e06812 --- /dev/null +++ b/client/cashcompass/lib/screens/add_category/add_category_screen.dart @@ -0,0 +1,116 @@ +import 'package:cashcompass_hook/src/accounts/category/category_icons.dart'; +import 'package:flutter/cupertino.dart'; + +class AddCategoryScreen extends StatefulWidget { + const AddCategoryScreen({Key? key}) : super(key: key); + + @override + State createState() => _AddCategoryScreenState(); +} + +class _AddCategoryScreenState extends State { + CategoryIcons selectedIcon = CategoryIcons.values[0]; + + _showPicker() async { + await showCupertinoModalPopup( + context: context, + builder: (BuildContext context) { + return Container( + height: 200, + padding: EdgeInsets.all(8.0), + color: CupertinoColors.white, // non-transparent background + child: CupertinoPicker( + itemExtent: 35, + onSelectedItemChanged: (index) { + setState(() { + selectedIcon = CategoryIcons.values[index]; + }); + }, + children: CategoryIcons.values + .map((icon) => Row( + children: [ + Icon(icon.icon), + SizedBox( + width: 10, + ), + Text(icon.name), + ], + )) + .toList(), + ), + ); + }, + ); + } + + @override + Widget build(BuildContext context) { + return CupertinoPageScaffold( + navigationBar: CupertinoNavigationBar( + middle: const Text("Add Category"), + ), + child: SafeArea( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: ListView( + children: [ + const Padding( + padding: EdgeInsets.symmetric(vertical: 8.0), + child: Row( + children: [ + SizedBox( + width: 25, + ), + Text("Title"), + SizedBox( + width: 50, + ), + Expanded( + child: CupertinoTextField(), + ) + ], + ), + ), + Padding( + padding: EdgeInsets.symmetric(vertical: 8.0), + child: Row( + children: [ + SizedBox( + width: 25, + ), + Text("Icon"), + SizedBox( + width: 50, + ), + Expanded( + child: CupertinoButton( + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Icon(selectedIcon.icon) + ]), // aligned to the left + onPressed: _showPicker, + ), + ), + ], + ), + ), + const SizedBox( + height: 10, + ), + Center( + child: CupertinoButton( + color: CupertinoColors.systemGreen, + onPressed: handleSaveNewCategory, + child: const Text("SAVE"), + ), + ), + ], + ), + ), + ), + ); + } + + void handleSaveNewCategory() {} +} diff --git a/client/cashcompass/lib/screens/categories_screen/categories_screen.dart b/client/cashcompass/lib/screens/categories_screen/categories_screen.dart index 0628290..01c7a51 100644 --- a/client/cashcompass/lib/screens/categories_screen/categories_screen.dart +++ b/client/cashcompass/lib/screens/categories_screen/categories_screen.dart @@ -1,12 +1,13 @@ import 'package:cashcompass/controller/controller.dart'; +import 'package:cashcompass/screens/add_category/add_category_screen.dart'; +import 'package:cashcompass_hook/src/accounts/category/category.dart'; +import 'package:cashcompass_hook/src/accounts/category/category_icons.dart'; +import 'package:cashcompass_hook/src/chart_of_accounts.dart/chart_of_accounts.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; + import '../../widgets/balance_overview/balance_overview.dart'; -import 'package:cashcompass_hook/src/chart_of_accounts.dart/chart_of_accounts.dart'; -import 'package:cashcompass_hook/src/data_storage/accout_manager.dart'; import '../../widgets/balance_overview/mock_transaction.dart'; -import 'package:cashcompass_hook/src/accounts/category/category.dart'; -import 'package:cashcompass_hook/src/accounts/category/category_icons.dart'; class CategoriesScreen extends StatefulWidget { const CategoriesScreen({super.key}); @@ -54,8 +55,15 @@ class _CategoriesScreenState extends State { @override Widget build(BuildContext context) { return CupertinoPageScaffold( - navigationBar: const CupertinoNavigationBar( - middle: Text("Categories"), + navigationBar: CupertinoNavigationBar( + middle: const Text("Categories"), + trailing: GestureDetector( + onTap: handleCreateCategory, + child: Icon( + CupertinoIcons.add, + size: 30.0, //you can adjust the size as needed + ), + ), ), child: SafeArea( child: SingleChildScrollView( @@ -67,7 +75,7 @@ class _CategoriesScreenState extends State { expenses: c2, ), ListView.builder( - physics: NeverScrollableScrollPhysics(), + physics: const NeverScrollableScrollPhysics(), shrinkWrap: true, itemCount: list.length + 1, itemBuilder: (context, index) { @@ -134,6 +142,11 @@ class _CategoriesScreenState extends State { void _handleCategoryListTileTapped() { throw UnsupportedError("Not yet implemented"); } + + void handleCreateCategory() { + Navigator.of(context).push( + CupertinoPageRoute(builder: (context) => const AddCategoryScreen())); + } } class InterpretedCategory { diff --git a/client/cashcompass/pubspec.lock b/client/cashcompass/pubspec.lock index e52914b..5b7f306 100644 --- a/client/cashcompass/pubspec.lock +++ b/client/cashcompass/pubspec.lock @@ -223,6 +223,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.15.0" + nested: + dependency: transitive + description: + name: nested + sha256: "03bac4c528c64c95c722ec99280375a6f2fc708eec17c7b3f07253b626cd2a20" + url: "https://pub.dev" + source: hosted + version: "1.0.0" path: dependency: transitive description: