Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
mrlanu committed Sep 3, 2023
2 parents 124a251 + 7688204 commit 5d8956a
Show file tree
Hide file tree
Showing 39 changed files with 1,447 additions and 556 deletions.
Binary file added assets/fonts/fa-brands-400.ttf
Binary file not shown.
Binary file added assets/fonts/fa-regular-400.ttf
Binary file not shown.
Binary file added assets/fonts/fa-solid-900.ttf
Binary file not shown.
119 changes: 56 additions & 63 deletions lib/account_edit/view/account_edit_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ import 'package:budget_app/account_edit/view/widgets/balance_input_field.dart';
import 'package:budget_app/account_edit/view/widgets/category_input_field.dart';
import 'package:budget_app/account_edit/view/widgets/include_switch.dart';
import 'package:budget_app/account_edit/view/widgets/name_input_field.dart';
import 'package:budget_app/app/repository/budget_repository.dart';
import 'package:budget_app/colors.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:formz/formz.dart';

class AccountEditDialog extends StatelessWidget {
Expand All @@ -18,62 +16,58 @@ class AccountEditDialog extends StatelessWidget {
return state.accStatus == AccountEditStatus.loading
? Center(child: CircularProgressIndicator())
: Center(
child: SingleChildScrollView(
child: Dialog(
insetPadding: EdgeInsets.all(10),
child: Stack(
clipBehavior: Clip.none,
alignment: Alignment.center,
children: <Widget>[
Container(
height: 1500.h,
width: double.infinity,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
color: BudgetColors.teal50,
child: SingleChildScrollView(
child: Dialog(
insetPadding: EdgeInsets.all(10),
child: Stack(
clipBehavior: Clip.none,
alignment: Alignment.center,
children: <Widget>[
Container(
height: 495,
width: double.infinity,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
color: BudgetColors.teal50,
),
padding: EdgeInsets.fromLTRB(20, 25, 20, 20),
child: Column(
children: [
Text(
'New Account',
style: TextStyle(
fontSize: Theme.of(context)
.textTheme
.titleLarge
?.fontSize),
),
SizedBox(
height: 20,
),
CategoryInputField(),
SizedBox(
height: 25,
),
NameInputField(),
SizedBox(
height: 25,
),
BalanceInputField(),
Divider(),
IncludeSwitch(),
Divider(),
_SubmitButton(),
],
),
),
padding: EdgeInsets.fromLTRB(20, 25, 20, 20),
child: Column(
children: [
Text(
'New Account',
style: TextStyle(
fontSize: Theme.of(context)
.textTheme
.titleLarge
?.fontSize),
),
SizedBox(
height: 50.h,
),
CategoryInputField(),
SizedBox(
height: 75.h,
),
NameInputField(),
SizedBox(
height: 75.h,
),
BalanceInputField(),
SizedBox(
height: 75.h,
),
IncludeSwitch(),
SizedBox(
height: 75.h,
),
_SubmitButton(),
],
),
),
/*Positioned(
/*Positioned(
top: -100,
child: Image.network("https://i.imgur.com/2yaf2wb.png",
width: 150, height: 150))*/
],
)),
),
);
],
)),
),
);
},
);
}
Expand All @@ -87,20 +81,19 @@ class _SubmitButton extends StatelessWidget {
builder: (context, state) {
return state.status.isInProgress
? const CircularProgressIndicator()
: ElevatedButton(
style: ElevatedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30),
),
backgroundColor:
Theme.of(context).colorScheme.primaryContainer,
),
: TextButton(
onPressed: state.isValid && state.category != null
? () => context
.read<AccountEditBloc>()
.add(AccountFormSubmitted(context: context))
: null,
child: Text('SAVE'),
child: Text('SAVE',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 20,
color: state.isValid && state.category != null
? BudgetColors.amber800
: Colors.grey)),
);
},
);
Expand Down
3 changes: 1 addition & 2 deletions lib/account_edit/view/widgets/include_switch.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:budget_app/account_edit/bloc/account_edit_bloc.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class IncludeSwitch extends StatelessWidget {
const IncludeSwitch({Key? key}) : super(key: key);
Expand All @@ -21,7 +20,7 @@ class IncludeSwitch extends StatelessWidget {
.titleLarge
?.fontSize),
),
SizedBox(width: 50.w,),
SizedBox(width: 10),
Switch(
thumbIcon: _thumbIcon,
value: state.isIncludeInTotals,
Expand Down
41 changes: 27 additions & 14 deletions lib/accounts_list/view/accounts_list_page.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import 'package:budget_app/account_edit/bloc/account_edit_bloc.dart';
import 'package:budget_app/account_edit/view/account_edit_form.dart';
import 'package:budget_app/accounts/repository/accounts_repository.dart';
import 'package:budget_app/categories/models/category.dart';
import 'package:budget_app/colors.dart';
import 'package:budget_app/home/cubit/home_cubit.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';

import '../../accounts/models/account.dart';
import '../../categories/repository/categories_repository.dart';
Expand All @@ -15,8 +14,7 @@ import '../cubit/accounts_list_cubit.dart';
class AccountsListPage extends StatelessWidget {
const AccountsListPage({Key? key}) : super(key: key);

static Route<void> route(
{required HomeCubit homeCubit}) {
static Route<void> route({required HomeCubit homeCubit}) {
return MaterialPageRoute(
fullscreenDialog: true,
builder: (context) {
Expand Down Expand Up @@ -47,7 +45,6 @@ class AccountsListView extends StatelessWidget {

@override
Widget build(BuildContext context) {
final scheme = Theme.of(context).colorScheme;
return MultiBlocListener(
listeners: [
BlocListener<AccountsListCubit, AccountsListState>(
Expand All @@ -68,14 +65,15 @@ class AccountsListView extends StatelessWidget {
],
child: BlocBuilder<AccountsListCubit, AccountsListState>(
builder: (context, state) {
final scheme = Theme.of(context).colorScheme;
return Scaffold(
appBar: AppBar(
title: Text('Accounts'),
),
body: Column(
children: [
SizedBox(
height: 50.h,
height: 10,
),
Expanded(
child: ListView.builder(
Expand All @@ -85,13 +83,28 @@ class AccountsListView extends StatelessWidget {
return Card(
elevation: Theme.of(context).cardTheme.elevation,
child: ListTile(
title: Text(
account.extendName(state.accountCategories),
style: TextStyle(
fontSize: Theme.of(context)
.textTheme
.titleLarge!
.fontSize),
title: Row(
children: [
Text(
account.extendName(state.accountCategories),
style: TextStyle(
fontSize: Theme.of(context)
.textTheme
.titleLarge!
.fontSize),
),
Expanded(child: Container()),
FaIcon(
color: scheme.primary,
IconData(
state.accountCategories
.firstWhere((element) =>
element.id ==
account.categoryId)
.iconCode ??
0,
fontFamily: 'FontAwesomeSolid')),
],
),
leading: IconButton(
icon: Icon(Icons.highlight_remove,
Expand All @@ -114,7 +127,7 @@ class AccountsListView extends StatelessWidget {
ListTile(
tileColor: BudgetColors.amber800,
title: Text(
'New Account',
'Add Account',
style: TextStyle(
fontSize:
Theme.of(context).textTheme.titleLarge!.fontSize),
Expand Down
10 changes: 1 addition & 9 deletions lib/app/view/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import 'package:budget_app/transfer/repository/transfer_repository.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:google_fonts/google_fonts.dart';

import '../../constants/constants.dart';
Expand Down Expand Up @@ -61,12 +60,7 @@ class _AppViewState extends State<AppView> {
Widget build(BuildContext context) {
w = MediaQuery.of(context).size.width;
h = MediaQuery.of(context).size.height;
return ScreenUtilInit(
designSize: const Size(1080, 2160),
minTextAdapt: true,
splitScreenMode: true,
builder: (context, child) {
return MultiRepositoryProvider(
return MultiRepositoryProvider(
providers: [
RepositoryProvider(create: (context) => BudgetRepositoryImpl()),
RepositoryProvider(create: (context) => CategoriesRepositoryImpl()),
Expand Down Expand Up @@ -147,7 +141,5 @@ class _AppViewState extends State<AppView> {
onGenerateRoute: (_) => SplashPage.route(),
),
);
},
);
}
}
18 changes: 13 additions & 5 deletions lib/categories/cubit/categories_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:bloc/bloc.dart';
import 'package:budget_app/constants/api.dart';
import 'package:budget_app/transactions/models/transaction_type.dart';
import 'package:equatable/equatable.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';

import '../models/category.dart';
import '../repository/categories_repository.dart';
Expand All @@ -29,23 +30,29 @@ class CategoriesCubit extends Cubit<CategoriesState> {
final catByType = categories
.where((element) => element.transactionType == state.transactionType)
.toList();
emit(state.copyWith(status: CategoriesStatus.success, categories: catByType));
emit(state.copyWith(
status: CategoriesStatus.success, categories: catByType));
}

void onNameChanged(String name) {
emit(state.copyWith(name: name));
}

void onIconCodeChanged(String code) {
emit(state.copyWith(iconCode: int.parse(code)));
void onIconCodeChanged(int code) {
print('Family: ${FontAwesomeIcons.code.fontFamily}');
print('CODE: ${FontAwesomeIcons.code.codePoint}');
emit(state.copyWith(iconCode: code));
}

void onNewCategory() {
emit(state.resetCategory());
}

void onCategoryEdit(Category category) {
emit(state.copyWith(editCategory: category));
emit(state.copyWith(
editCategory: category,
name: category.name,
iconCode: category.iconCode));
}

Future<void> onSubmit() async {
Expand All @@ -57,7 +64,8 @@ class CategoriesCubit extends Cubit<CategoriesState> {
budgetId: await getBudgetId(),
transactionType: state.transactionType);
} else {
category = state.editCategory!.copyWith(name: state.name, iconCode: state.iconCode);
category = state.editCategory!
.copyWith(name: state.name, iconCode: state.iconCode);
}
_categoriesRepository.saveCategory(category: category);
emit(state.copyWith(status: CategoriesStatus.loading));
Expand Down
8 changes: 4 additions & 4 deletions lib/categories/cubit/categories_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class CategoriesState extends Equatable {
final List<Category> categories;
final TransactionType transactionType;
final String? name;
final int? iconCode;
final int iconCode;
final Category? editCategory;
final String? errorMessage;

Expand All @@ -16,7 +16,7 @@ class CategoriesState extends Equatable {
this.categories = const [],
this.transactionType = TransactionType.EXPENSE,
this.name,
this.iconCode,
this.iconCode = -1,
this.editCategory,
this.errorMessage});

Expand All @@ -43,8 +43,8 @@ class CategoriesState extends Equatable {
status: this.status,
categories: this.categories,
transactionType: this.transactionType,
name: this.name,
iconCode: this.iconCode,
name: null,
iconCode: 0,
editCategory: null);
}

Expand Down
Loading

0 comments on commit 5d8956a

Please sign in to comment.