Skip to content

Commit

Permalink
Merge pull request #40 from steven-kamanga/account's-card
Browse files Browse the repository at this point in the history
Implemented Account's Card UI design.
  • Loading branch information
zikani03 authored Nov 24, 2023
2 parents 13a2884 + 03e3fdd commit 149baaf
Show file tree
Hide file tree
Showing 8 changed files with 374 additions and 227 deletions.
37 changes: 18 additions & 19 deletions app/lib/data/database.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ dynamic encrypter(String password) {
return encrypted;
}


/// Update Company table V1 to V2
void _addIsFavouriteToAccountsTableV2(Batch batch) {
batch.execute('ALTER TABLE accounts ADD isFavourite boolean default FALSE;');
Expand All @@ -24,23 +23,23 @@ class DbManager {

Future openDb() async {
_database = await openDatabase(
join(await getDatabasesPath(), "bankimoon.db"),
version: 2,
onCreate: (Database db, int version) async {
await db.execute(
"CREATE TABLE IF NOT EXISTS accounts(id INTEGER PRIMARY KEY autoincrement, bankName TEXT, accountName TEXT, accountNumber INTEGER)",
);
await db.execute(
"CREATE TABLE IF NOT EXISTS password(id INTEGER PRIMARY KEY autoincrement, password TEXT)",
);
},
onUpgrade: (db, oldVersion, newVersion) async {
var batch = db.batch();
if (oldVersion == 1) {
_addIsFavouriteToAccountsTableV2(batch);
}
await batch.commit();
},
join(await getDatabasesPath(), "bankimoon.db"),
version: 3,
onCreate: (Database db, int version) async {
await db.execute(
"CREATE TABLE IF NOT EXISTS accounts(id INTEGER PRIMARY KEY autoincrement, bankName TEXT, accountName TEXT, accountNumber INTEGER, isFavourite TEXT)",
);
await db.execute(
"CREATE TABLE IF NOT EXISTS password(id INTEGER PRIMARY KEY autoincrement, password TEXT)",
);
},
onUpgrade: (db, oldVersion, newVersion) async {
var batch = db.batch();
if (oldVersion == 1) {
_addIsFavouriteToAccountsTableV2(batch);
}
await batch.commit();
},
);
return _database;
}
Expand Down Expand Up @@ -158,7 +157,7 @@ class DbManager {

String sql = "UPDATE accounts SET isFavourite = 1 WHERE id = ?";

List<dynamic> params = [ accountId ];
List<dynamic> params = [accountId];

return await _database.rawQuery(sql, params);
}
Expand Down
2 changes: 1 addition & 1 deletion app/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Future<void> main() async {
theme: ThemeData(
useMaterial3: true,
fontFamily: GoogleFonts.lato().fontFamily,
colorSchemeSeed: Colors.deepPurple,
// colorSchemeSeed: Colors.deepPurple,
appBarTheme: AppBarTheme(
backgroundColor: Colors.deepPurple[800],
),
Expand Down
26 changes: 13 additions & 13 deletions app/lib/presentation/screens/favourites.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:bankimoon/data/cubit/accounts_cubit.dart';
import 'package:bankimoon/presentation/widgets/account_card.dart';
import 'package:bankimoon/presentation/widgets/card.dart';
import 'package:bankimoon/utils/constants.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
Expand All @@ -19,13 +19,13 @@ class Favourite extends StatelessWidget {
),
centerTitle: true,
leading: GestureDetector(
onTap: () {
Navigator.pop(context);
},
child: const Icon(
Icons.arrow_back,
color: Colors.white,
)),
onTap: () {
Navigator.pop(context);
},
child: const Icon(
Icons.arrow_back,
color: Colors.white,
)),
bottom: PreferredSize(
preferredSize: const Size.fromHeight(50.0),
child: Padding(
Expand All @@ -40,7 +40,8 @@ class Favourite extends StatelessWidget {
BlocProvider.of<AccountsCubit>(context)
.searchFavouriteAccounts(value.toString());
} else {
BlocProvider.of<AccountsCubit>(context).favouritedAccounts();
BlocProvider.of<AccountsCubit>(context)
.favouritedAccounts();
}
},
),
Expand Down Expand Up @@ -234,10 +235,9 @@ class Favourite extends StatelessWidget {
height: size.height,
width: size.width,
child: Center(
child: Text(
state.message,
)
),
child: Text(
state.message,
)),
);
} else {
return SizedBox(
Expand Down
91 changes: 4 additions & 87 deletions app/lib/presentation/screens/home.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import 'package:bankimoon/data/cubit/accounts_cubit.dart';
import 'package:bankimoon/presentation/widgets/account_card.dart';
import 'package:bankimoon/presentation/widgets/card.dart';
import 'package:bankimoon/utils/constants.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

import '../widgets/nav_bar.dart';

class Home extends StatelessWidget {
const Home({super.key});

Expand Down Expand Up @@ -244,92 +246,7 @@ class Home extends StatelessWidget {
}
},
),
bottomNavigationBar: BottomAppBar(
color: Color.fromARGB(255, 15, 91, 254),
shape: const CircularNotchedRectangle(),
padding:
EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
IconButton(
// ignore: prefer_const_constructors
icon: Icon(
Icons.home,
color: Colors.white, // Set the icon color to white
),
onPressed: () {
Navigator.pushNamed(context, Home as String);
},
),
// ignore: prefer_const_constructors
Text(
'Home',
// ignore: prefer_const_constructors
style: TextStyle(color: Colors.white),
),
],
),
Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
IconButton(
// ignore: prefer_const_constructors
icon: Icon(
Icons.favorite,
color: Colors.white, // Set the icon color to white
),
onPressed: () {
Navigator.pushNamed(context, favouritePage);
},
),
// ignore: prefer_const_constructors
Text(
'Favorites',
style: TextStyle(color: Colors.white),
),
],
),
Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
IconButton(
icon: Icon(
Icons.add,
color: Colors.white, // Set the icon color to white
),
onPressed: () {
Navigator.pushNamed(context, addAccount);
},
),
Text(
'Add Account',
style: TextStyle(color: Colors.white),
),
],
),
Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
IconButton(
icon: Icon(
Icons.account_circle,
color: Colors.white, // Set the icon color to white
),
onPressed: () {},
),
Text(
'My Accounts',
style: TextStyle(color: Colors.white),
),
],
),
],
),
),
bottomNavigationBar: const BottomNavBar(),
);
}
}
94 changes: 0 additions & 94 deletions app/lib/presentation/widgets/account_card.dart

This file was deleted.

Loading

0 comments on commit 149baaf

Please sign in to comment.