Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Mathisi/feature/104 UI create add category page #282

Merged
merged 3 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 116 additions & 0 deletions client/cashcompass/lib/screens/add_category/add_category_screen.dart
Original file line number Diff line number Diff line change
@@ -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<AddCategoryScreen> createState() => _AddCategoryScreenState();
}

class _AddCategoryScreenState extends State<AddCategoryScreen> {
CategoryIcons selectedIcon = CategoryIcons.values[0];

_showPicker() async {
await showCupertinoModalPopup<void>(
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() {}
}
Original file line number Diff line number Diff line change
@@ -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});
Expand Down Expand Up @@ -54,8 +55,15 @@ class _CategoriesScreenState extends State<CategoriesScreen> {
@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(
Expand All @@ -67,7 +75,7 @@ class _CategoriesScreenState extends State<CategoriesScreen> {
expenses: c2,
),
ListView.builder(
physics: NeverScrollableScrollPhysics(),
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: list.length + 1,
itemBuilder: (context, index) {
Expand Down Expand Up @@ -134,6 +142,11 @@ class _CategoriesScreenState extends State<CategoriesScreen> {
void _handleCategoryListTileTapped() {
throw UnsupportedError("Not yet implemented");
}

void handleCreateCategory() {
Navigator.of(context).push(
CupertinoPageRoute(builder: (context) => const AddCategoryScreen()));
}
}

class InterpretedCategory {
Expand Down
8 changes: 8 additions & 0 deletions client/cashcompass/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down