Skip to content

Commit

Permalink
updated password list
Browse files Browse the repository at this point in the history
  • Loading branch information
drriguz committed Feb 21, 2025
1 parent 5307800 commit bc37340
Show file tree
Hide file tree
Showing 17 changed files with 406 additions and 19 deletions.
Binary file added assets/fonts/MyIcons.ttf
Binary file not shown.
2 changes: 0 additions & 2 deletions lib/src/database/database.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import 'dart:io';
import 'dart:ffi';

import 'package:convert/convert.dart';
import 'package:drift/drift.dart';
import 'package:drift/native.dart';
import 'package:flutter/foundation.dart';
import 'package:kdbx/kdbx.dart';
import 'package:path/path.dart' as p;
import 'package:path_provider/path_provider.dart';
Expand Down
30 changes: 30 additions & 0 deletions lib/src/my_icons_icons.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/// Flutter icons MyIcons
/// Copyright (C) 2025 by original authors @ fluttericon.com, fontello.com
/// This font was generated by FlutterIcon.com, which is derived from Fontello.
///
/// To use this font, place it in your fonts/ directory and include the
/// following in your pubspec.yaml
///
/// flutter:
/// fonts:
/// - family: MyIcons
/// fonts:
/// - asset: fonts/MyIcons.ttf
///
///
/// * Linearicons Free, Copyright (C) Linearicons.com
/// Author: Perxis
/// License: CC BY-SA 4.0 (https://creativecommons.org/licenses/by-sa/4.0/)
/// Homepage: https://linearicons.com
///
import 'package:flutter/widgets.dart';

class MyIcons {
MyIcons._();

static const _kFontFam = 'MyIcons';
static const String? _kFontPkg = null;

static const IconData chevron_down = IconData(0xe874, fontFamily: _kFontFam, fontPackage: _kFontPkg);
static const IconData chevron_right = IconData(0xe876, fontFamily: _kFontFam, fontPackage: _kFontPkg);
}
27 changes: 21 additions & 6 deletions lib/src/providers.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import 'package:cryptowl/main.dart';
import 'package:flutter/foundation.dart';
import 'package:cryptowl/src/service/password_repository.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:kdbx/kdbx.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

import 'config/meta.dart';
import 'database/database.dart';
import 'domain/user.dart';
import 'service/app_service.dart';
import 'service/category_repository.dart';
import 'service/kdbx_service.dart';
import 'service/password_service.dart';

Expand All @@ -28,26 +27,42 @@ PasswordService passwordService(Ref ref) {
return PasswordService();
}

@riverpod
PasswordRepository passwordRepository(Ref ref) {
final db = ref.watch(userDatabaseProvider);
return PasswordRepository(db);
}

@riverpod
CategoryRepository categoryRepository(Ref ref) {
final db = ref.watch(userDatabaseProvider);
return CategoryRepository(db);
}

@Riverpod(keepAlive: true)
class CurrentUser extends _$CurrentUser {
@override
User? build() {
return null;
}

void setUser(User user) => state = user;
void setUser(User? user) => state = user;
}

@Riverpod(keepAlive: true)
@Riverpod(keepAlive: false)
AppDb userDatabase(Ref ref) {
logger.fine("opening user db...");
final currentUser = ref.watch(currentUserProvider);
if (currentUser == null) {
logger.severe("Current user not logged in!");
throw Exception("User not login");
}
final meta = currentUser.meta;
final db = AppDb.open("${meta.dbInstance}.enc", meta.dbEncryptionKey);
ref.onDispose(() => db.close());
ref.onDispose(() {
logger.fine("Disposing db...");
db.close();
});
return db;
}

Expand Down
46 changes: 42 additions & 4 deletions lib/src/providers.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions lib/src/screens/components/app_drawer.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

import '../login.dart';

class AppDrawer extends ConsumerWidget {
const AppDrawer({super.key});

@override
Widget build(BuildContext context, WidgetRef ref) {
final loginNotifier = ref.watch(loginStateProvider.notifier);

return Drawer(
child: ListView(
// Important: Remove any padding from the ListView.
padding: EdgeInsets.zero,
children: [
const DrawerHeader(
child: Text('Cryptowl 0.1'),
),
ListTile(
title: const Text('Backup'),
onTap: () {
// Update the state of the app.
// ...
},
),
ListTile(
title: const Text('Logout'),
onTap: () async {
await loginNotifier.logout();
},
),
],
),
);
}
}
33 changes: 33 additions & 0 deletions lib/src/screens/components/category_group.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import 'package:flutter/material.dart';

import '../../my_icons_icons.dart';

class CategoryGroup extends StatelessWidget {
final String name;

const CategoryGroup({super.key, required this.name});

@override
Widget build(BuildContext context) {
return InkWell(
child: Row(
children: [
Icon(
MyIcons.chevron_right,
size: 12,
),
Padding(
padding: EdgeInsets.only(left: 10),
child: Text(
name,
style: TextStyle(
color: Colors.grey,
),
),
),
],
),
onTap: () {},
);
}
}
18 changes: 16 additions & 2 deletions lib/src/screens/components/category_item.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
import 'package:flutter/material.dart';

class CategoryItem extends StatelessWidget {
final String name;
final IconData icon;
final int count;

const CategoryItem(
{super.key, required this.name, required this.icon, required this.count});

@override
Widget build(BuildContext context) {
// TODO: implement build
throw UnimplementedError();
return ListTile(
dense: true,
contentPadding: EdgeInsets.only(right: 10),
visualDensity: VisualDensity(horizontal: 0, vertical: -4),
leading: Icon(icon),
title: Text(name),
trailing: Text("$count"),
onTap: () {},
);
}
}
85 changes: 85 additions & 0 deletions lib/src/screens/components/password_categories.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

import '../../domain/category.dart';
import '../../providers.dart';
import '../passwords.dart';
import 'category_group.dart';
import 'category_item.dart';

part 'password_categories.g.dart';

@riverpod
Future<List<Category>> categories(Ref ref) async {
return ref.watch(categoryRepositoryProvider).list();
}

class PasswordCategories extends ConsumerWidget {
const PasswordCategories({super.key});

@override
Widget build(BuildContext context, WidgetRef ref) {
final categories = ref.watch(categoriesProvider);

return SingleChildScrollView(
child: Column(
children: [
CategoryItem(
name: "All items",
icon: Icons.dashboard,
count: 10,
),
CategoryItem(
name: "Favourite",
icon: Icons.favorite,
count: 10,
),
CategoryItem(
name: "Trash",
icon: Icons.recycling,
count: 10,
),
SizedBox(height: 15),
CategoryGroup(name: "TYPES"),
CategoryItem(
name: "Login",
icon: Icons.recycling,
count: 10,
),
CategoryItem(
name: "Card",
icon: Icons.recycling,
count: 10,
),
CategoryItem(
name: "SSH Key",
icon: Icons.recycling,
count: 10,
),
SizedBox(height: 15),
CategoryGroup(name: "CATEGORIES"),
categories.when(
data: (list) {
return Column(
children: [
...list.map((c) {
return CategoryItem(
name: c.name,
icon: Icons.folder_outlined,
count: 10,
);
})
],
);
},
loading: () => const Center(
child: CircularProgressIndicator(),
),
error: (e, _) => ErrorWidget(e),
),
],
),
);
}
}
26 changes: 26 additions & 0 deletions lib/src/screens/components/password_categories.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit bc37340

Please sign in to comment.