Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/alexandrim0/keyper
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrsosnin committed Dec 23, 2023
2 parents 11f8eef + d65a4da commit 07b0f6d
Show file tree
Hide file tree
Showing 36 changed files with 99 additions and 124 deletions.
4 changes: 3 additions & 1 deletion lib/app/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ class App extends StatelessWidget with ThemeModeMapper {
final themeModeHandler = SettingsThemeCase();
final sentryNavigatorObserver = SentryNavigatorObserver();
return StreamBuilder<ThemeMode>(
initialData: mapBoolToThemeMode(themeModeHandler.isDarkMode),
// TBD: light color scheme
// initialData: mapBoolToThemeMode(themeModeHandler.isDarkMode),
initialData: ThemeMode.dark,
stream: themeModeHandler.events.map<ThemeMode>(mapBoolToThemeMode),
builder: (context, snapshot) {
SystemChrome.setSystemUIOverlayStyle(switch (snapshot.data) {
Expand Down
1 change: 0 additions & 1 deletion lib/app/di.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'dart:typed_data';
import 'package:hive/hive.dart';
import 'package:get_it/get_it.dart';

import 'package:guardian_keyper/data/services/platform_service.dart';
import 'package:guardian_keyper/data/services/analytics_service.dart';
Expand Down
4 changes: 1 addition & 3 deletions lib/feature/home/ui/dev_panel_screen.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import 'package:get_it/get_it.dart';

import 'package:guardian_keyper/app/routes.dart';
import 'package:guardian_keyper/data/repositories/settings_repository.dart';
import 'package:guardian_keyper/ui/widgets/common.dart';
import 'package:guardian_keyper/data/repositories/settings_repository.dart';

import 'package:guardian_keyper/feature/vault/domain/entity/vault.dart';
import 'package:guardian_keyper/feature/vault/domain/entity/vault_id.dart';
Expand Down
1 change: 0 additions & 1 deletion lib/feature/home/ui/home_screen.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'dart:async';
import 'package:get_it/get_it.dart';
import 'package:flutter_svg/flutter_svg.dart';

import 'package:guardian_keyper/consts.dart';
Expand Down
1 change: 0 additions & 1 deletion lib/feature/home/ui/pages/home_page.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:get_it/get_it.dart';
import 'package:flutter/foundation.dart';

import 'package:guardian_keyper/app/routes.dart';
Expand Down
1 change: 0 additions & 1 deletion lib/feature/home/ui/pages/home_shards_page.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:get_it/get_it.dart';
import 'package:flutter_svg/flutter_svg.dart';

import 'package:guardian_keyper/app/routes.dart';
Expand Down
2 changes: 0 additions & 2 deletions lib/feature/home/ui/pages/home_vault_page.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'package:get_it/get_it.dart';

import 'package:guardian_keyper/app/routes.dart';
import 'package:guardian_keyper/ui/widgets/common.dart';
import 'package:guardian_keyper/ui/utils/screen_size.dart';
Expand Down
2 changes: 0 additions & 2 deletions lib/feature/intro/ui/intro_presenter.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'package:get_it/get_it.dart';

import 'package:guardian_keyper/consts.dart';
import 'package:guardian_keyper/ui/presenters/page_presenter_base.dart';
import 'package:guardian_keyper/feature/network/data/network_manager.dart';
Expand Down
2 changes: 0 additions & 2 deletions lib/feature/message/domain/use_case/message_egress_mixin.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'package:get_it/get_it.dart';

import 'package:guardian_keyper/feature/network/data/network_manager.dart';
import 'package:guardian_keyper/feature/message/domain/entity/message_model.dart';
import 'package:guardian_keyper/feature/vault/domain/entity/secret_shard.dart';
Expand Down
2 changes: 0 additions & 2 deletions lib/feature/message/domain/use_case/message_interactor.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'package:get_it/get_it.dart';

import 'package:guardian_keyper/feature/vault/domain/entity/vault.dart';
import 'package:guardian_keyper/feature/vault/domain/entity/vault_id.dart';
import 'package:guardian_keyper/feature/network/domain/entity/peer_id.dart';
Expand Down
3 changes: 1 addition & 2 deletions lib/feature/message/ui/message_home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import 'package:guardian_keyper/feature/message/domain/entity/message_model.dart
import 'message_home_presenter.dart';
import 'widgets/message_list_tile.dart';
import 'dialogs/on_message_archivate_dialog.dart';
// import 'widgets/resolved_messages_tab.dart';
// import 'widgets/active_messages_tab.dart';

class MessageHomeScreen extends StatelessWidget {
const MessageHomeScreen({super.key});
Expand All @@ -23,6 +21,7 @@ class MessageHomeScreen extends StatelessWidget {
final presenter = context.watch<MessageHomePresenter>();
return ScaffoldSafe(
isSeparated: true,
isSeparatorSmall: true,
header: isTitleVisible
? AppBar(
title: const Text('Requests'),
Expand Down
4 changes: 4 additions & 0 deletions lib/feature/network/data/network_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import 'network_service.dart';
import 'mdns_service.dart';
import 'router_service.dart';

export 'package:get_it/get_it.dart';

enum NetworkManagerStatus { uninited, stopped, started, pending }

typedef NetworkManagerState = ({
Expand Down Expand Up @@ -144,6 +146,7 @@ class NetworkManager {
}

Future<void> setDeviceName(String value) async {
if (_selfId.name == value) return;
_selfId = _selfId.copyWith(name: value);
await _preferencesService.set<String>(
PreferencesKeys.keyDeviceName,
Expand All @@ -153,6 +156,7 @@ class NetworkManager {
}

Future<void> setBootstrap({required bool isEnabled}) async {
if (_isBootstrapEnabled == isEnabled) return;
_isBootstrapEnabled = isEnabled;
await _preferencesService.set<bool>(
PreferencesKeys.keyIsBootstrapEnabled,
Expand Down
77 changes: 45 additions & 32 deletions lib/feature/settings/ui/dialogs/on_set_device_name_dialog.dart
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
import 'package:guardian_keyper/consts.dart';
import 'package:guardian_keyper/ui/widgets/common.dart';

import '../settings_presenter.dart';
import 'package:guardian_keyper/feature/network/data/network_manager.dart';

class OnSetDeviceNameDialog extends StatelessWidget {
static Future<void> show(BuildContext context) {
final presenter = context.read<SettingsPresenter>();
return Navigator.of(context).push(MaterialPageRoute(
fullscreenDialog: true,
builder: (_) => ChangeNotifierProvider.value(
value: presenter,
child: OnSetDeviceNameDialog(presenter: presenter),
),
));
}
class OnSetDeviceNameDialog extends StatefulWidget {
static Future<void> show(BuildContext context) =>
Navigator.of(context).push(MaterialPageRoute(
fullscreenDialog: true,
builder: (_) => const OnSetDeviceNameDialog(),
));

const OnSetDeviceNameDialog({super.key});

@override
State<OnSetDeviceNameDialog> createState() => _OnSetDeviceNameDialogState();
}

class _OnSetDeviceNameDialogState extends State<OnSetDeviceNameDialog> {
final _networkManager = GetIt.I<NetworkManager>();

const OnSetDeviceNameDialog({
required this.presenter,
super.key,
});
late final _inputController = TextEditingController(
text: _networkManager.selfId.name,
);

final SettingsPresenter presenter;
late bool _canProceed = _networkManager.selfId.name.length >= minNameLength;

@override
void dispose() {
_inputController.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) => ScaffoldSafe(
Expand All @@ -32,31 +41,35 @@ class OnSetDeviceNameDialog extends StatelessWidget {
const PageTitle(title: 'Create new Device name'),
Padding(
padding: paddingV20,
child: TextFormField(
child: TextField(
autofocus: true,
keyboardType: TextInputType.text,
maxLength: maxNameLength,
initialValue: presenter.deviceName,
onChanged: (value) => presenter.deviceName = value,
controller: _inputController,
keyboardType: TextInputType.text,
decoration: const InputDecoration(
labelText: ' Device name ',
helperText: 'Minimum $minNameLength characters',
),
onChanged: (value) {
if (value.length >= minNameLength && !_canProceed) {
setState(() => _canProceed = true);
} else if (value.length < minNameLength && _canProceed) {
setState(() => _canProceed = false);
}
},
),
),
// Footer
Padding(
padding: paddingV20,
child: Consumer<SettingsPresenter>(
builder: (context, presenter, __) => FilledButton(
onPressed: presenter.hasMinimumDeviceNameLength
? () async {
await presenter.setDeviceName();
if (context.mounted) Navigator.of(context).pop();
}
: null,
child: const Text('Proceed'),
),
child: FilledButton(
onPressed: _canProceed
? () async {
await _networkManager
.setDeviceName(_inputController.value.text);
if (context.mounted) Navigator.of(context).pop();
}
: null,
child: const Text('Proceed'),
),
),
],
Expand Down
17 changes: 0 additions & 17 deletions lib/feature/settings/ui/settings_presenter.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import 'package:get_it/get_it.dart';
import 'package:flutter/material.dart';

import 'package:guardian_keyper/consts.dart';
import 'package:guardian_keyper/ui/utils/theme_mode_mapper.dart';

import 'package:guardian_keyper/feature/auth/data/auth_manager.dart';
Expand All @@ -26,8 +24,6 @@ class SettingsPresenter extends ChangeNotifier with ThemeModeMapper {

final _networkManager = GetIt.I<NetworkManager>();

late String _deviceName = _networkManager.selfId.name;

bool _hasBiometrics = false;

bool get hasBiometrics => _hasBiometrics;
Expand All @@ -38,22 +34,9 @@ class SettingsPresenter extends ChangeNotifier with ThemeModeMapper {

bool get isBootstrapEnabled => _networkManager.isBootstrapEnabled;

bool get hasMinimumDeviceNameLength => _deviceName.length >= minNameLength;

ThemeMode get selectedThemeMode =>
mapBoolToThemeMode(_themeModeHandler.isDarkMode);

set deviceName(String value) {
_deviceName = value;
notifyListeners();
}

Future<void> setDeviceName() async {
if (_networkManager.selfId.name == _deviceName) return;
await _networkManager.setDeviceName(_deviceName);
notifyListeners();
}

Future<void> setBootstrap(bool isEnabled) async {
await _networkManager.setBootstrap(isEnabled: isEnabled);
notifyListeners();
Expand Down
2 changes: 2 additions & 0 deletions lib/feature/vault/domain/use_case/vault_interactor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import 'vault_platform_mixin.dart';
import 'vault_network_mixin.dart';
import 'vault_sss_mixin.dart';

export 'package:get_it/get_it.dart';

/// Depends on:
/// [
/// PreferencesService,
Expand Down
2 changes: 0 additions & 2 deletions lib/feature/vault/domain/use_case/vault_network_mixin.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'package:get_it/get_it.dart';

import 'package:guardian_keyper/feature/network/data/network_manager.dart';
import 'package:guardian_keyper/feature/network/domain/entity/peer_id.dart';
import 'package:guardian_keyper/feature/message/domain/entity/message_model.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'dart:async';
import 'package:get_it/get_it.dart';

import 'package:guardian_keyper/feature/vault/domain/entity/vault_id.dart';
import 'package:guardian_keyper/feature/vault/domain/use_case/vault_interactor.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'package:get_it/get_it.dart';

import 'package:guardian_keyper/consts.dart';
import 'package:guardian_keyper/data/repositories/settings_repository.dart';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:get_it/get_it.dart';
import 'package:flutter/services.dart';

import 'package:guardian_keyper/feature/message/domain/entity/message_model.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'package:get_it/get_it.dart';

import 'package:guardian_keyper/ui/widgets/common.dart';
import 'package:guardian_keyper/ui/widgets/icon_of.dart';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'package:get_it/get_it.dart';

import 'package:guardian_keyper/consts.dart';
import 'package:guardian_keyper/ui/presenters/page_presenter_base.dart';
import 'package:guardian_keyper/feature/vault/domain/entity/vault.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// ignore_for_file: parameter_assignments

import 'dart:async';
import 'package:get_it/get_it.dart';

import 'package:guardian_keyper/feature/message/domain/entity/message_model.dart';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'package:get_it/get_it.dart';

import 'package:guardian_keyper/ui/widgets/common.dart';

import 'package:guardian_keyper/feature/vault/domain/entity/vault.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'package:get_it/get_it.dart';

import 'package:guardian_keyper/ui/widgets/common.dart';

import 'package:guardian_keyper/feature/vault/domain/entity/vault_id.dart';
Expand Down
2 changes: 0 additions & 2 deletions lib/feature/vault/ui/_vault_show/vault_show_screen.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'package:get_it/get_it.dart';

import 'package:guardian_keyper/app/routes.dart';
import 'package:guardian_keyper/ui/widgets/common.dart';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'package:get_it/get_it.dart';

import 'package:guardian_keyper/ui/widgets/common.dart';

import 'package:guardian_keyper/feature/network/domain/entity/peer_id.dart';
Expand Down
6 changes: 2 additions & 4 deletions lib/feature/vault/ui/dialogs/on_code_input_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class _OnCodeInputDialogState extends State<OnCodeInputDialog> {
child: TextField(
autofocus: true,
controller: _controller,
enableInteractiveSelection: false,
decoration: const InputDecoration(labelText: ' Code '),
),
),
Expand Down Expand Up @@ -75,10 +76,7 @@ class _OnCodeInputDialogState extends State<OnCodeInputDialog> {
child: FilledButton(
onPressed: () =>
Navigator.of(context).pop(_controller.text),
child: const Text(
'Add',
overflow: TextOverflow.ellipsis,
),
child: const Text('Add'),
),
),
],
Expand Down
2 changes: 0 additions & 2 deletions lib/feature/vault/ui/dialogs/on_version_low.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'package:get_it/get_it.dart';

import 'package:guardian_keyper/ui/widgets/common.dart';

import 'package:guardian_keyper/feature/vault/domain/use_case/vault_interactor.dart';
Expand Down
2 changes: 0 additions & 2 deletions lib/feature/vault/ui/vault_guardian_presenter_base.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'package:get_it/get_it.dart';

import 'package:guardian_keyper/feature/message/domain/entity/message_model.dart';
import 'package:guardian_keyper/feature/vault/domain/use_case/vault_interactor.dart';
import 'package:guardian_keyper/feature/vault/domain/entity/vault_id.dart';
Expand Down
1 change: 0 additions & 1 deletion lib/feature/vault/ui/vault_presenter_base.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'dart:async';
import 'package:get_it/get_it.dart';

import 'package:guardian_keyper/consts.dart';
import 'package:guardian_keyper/ui/presenters/page_presenter_base.dart';
Expand Down
1 change: 0 additions & 1 deletion lib/feature/vault/ui/vault_secret_presenter_base.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'dart:async';
import 'package:get_it/get_it.dart';

import 'package:guardian_keyper/feature/network/domain/entity/peer_id.dart';
import 'package:guardian_keyper/feature/message/domain/entity/message_model.dart';
Expand Down
2 changes: 2 additions & 0 deletions lib/ui/theme/theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ final themeData = ThemeData(
// AppBar
appBarTheme: const AppBarTheme(
centerTitle: true,
elevation: 0,
shadowColor: Colors.transparent,
toolbarHeight: toolbarHeight,
),
// Bottom Navigation Bar
Expand Down
3 changes: 2 additions & 1 deletion lib/ui/theme/theme_dark.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ final colorSchemeDark = ColorScheme.fromSeed(
surface: const Color(0xFF24035F),
onSurface: const Color(0xFFE6DEF8),
onSurfaceVariant: const Color(0xFFE6DEF8),
// onSurfaceVariant: const Color(0xFFA066F5),
);

final themeDark = themeData.copyWith(
Expand All @@ -44,6 +43,8 @@ final themeDark = themeData.copyWith(
// AppBar
appBarTheme: themeData.appBarTheme.copyWith(
backgroundColor: colorSchemeDark.background,
surfaceTintColor: colorSchemeDark.background,
systemOverlayStyle: systemStyleDark,
),
// Bottom Navigation Bar
bottomNavigationBarTheme: themeData.bottomNavigationBarTheme.copyWith(
Expand Down
Loading

0 comments on commit 07b0f6d

Please sign in to comment.