mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-23 09:16:54 +00:00
update
This commit is contained in:
parent
d0023e5718
commit
4942f67f37
|
@ -2,7 +2,7 @@ import 'package:get_it/get_it.dart';
|
|||
import 'package:selfprivacy/logic/get_it/api_config.dart';
|
||||
import 'package:selfprivacy/logic/get_it/console.dart';
|
||||
import 'package:selfprivacy/logic/get_it/navigation.dart';
|
||||
import 'package:selfprivacy/logic/get_it/ssh_helper.dart';
|
||||
import 'package:selfprivacy/logic/get_it/ssh.dart';
|
||||
import 'package:selfprivacy/logic/get_it/timer.dart';
|
||||
|
||||
export 'package:selfprivacy/logic/get_it/api_config.dart';
|
||||
|
|
|
@ -2,7 +2,9 @@ import 'dart:async';
|
|||
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:selfprivacy/config/get_it_config.dart';
|
||||
import 'package:selfprivacy/logic/cubit/services/services_cubit.dart';
|
||||
import 'package:selfprivacy/logic/get_it/ssh.dart';
|
||||
import 'package:selfprivacy/logic/models/backblaze_credential.dart';
|
||||
import 'package:selfprivacy/logic/models/cloudflare_domain.dart';
|
||||
|
||||
|
@ -274,6 +276,7 @@ class AppConfigCubit extends Cubit<AppConfigState> {
|
|||
|
||||
if (state.hetznerServer != null) {
|
||||
await repository.deleteServer(state.cloudFlareDomain!);
|
||||
await getIt<SSHModel>().clear();
|
||||
}
|
||||
await repository.deleteRecords();
|
||||
emit(AppConfigState(
|
||||
|
|
|
@ -6,7 +6,6 @@ import 'hetzner_metrics_cubit.dart';
|
|||
|
||||
class HetznerMetricsRepository {
|
||||
Future<HetznerMetricsLoaded> getMetrics(Period period) async {
|
||||
print(period);
|
||||
var end = DateTime.now();
|
||||
DateTime start;
|
||||
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:selfprivacy/config/brand_colors.dart';
|
||||
import 'package:selfprivacy/config/get_it_config.dart';
|
||||
import 'package:selfprivacy/config/text_themes.dart';
|
||||
import 'package:selfprivacy/logic/api_maps/server.dart';
|
||||
import 'package:selfprivacy/logic/cubit/services/services_cubit.dart';
|
||||
import 'package:selfprivacy/logic/cubit/users/users_cubit.dart';
|
||||
import 'package:selfprivacy/logic/get_it/ssh_helper.dart';
|
||||
import 'package:selfprivacy/logic/get_it/ssh.dart';
|
||||
import 'package:selfprivacy/logic/models/job.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:selfprivacy/logic/models/user.dart';
|
||||
|
@ -29,10 +31,7 @@ class JobsCubit extends Cubit<JobsState> {
|
|||
newJobsList.addAll((state as JobsStateWithJobs).jobList);
|
||||
}
|
||||
newJobsList.add(job);
|
||||
getIt<NavigationService>().showSnackBar(SnackBar(
|
||||
content: Text('jobs.jobAdded'.tr()),
|
||||
duration: const Duration(seconds: 2),
|
||||
));
|
||||
getIt<NavigationService>().showSnackBar('jobs.jobAdded'.tr());
|
||||
emit(JobsStateWithJobs(newJobsList));
|
||||
}
|
||||
|
||||
|
@ -54,10 +53,7 @@ class JobsCubit extends Cubit<JobsState> {
|
|||
removeJob(removingJob.id);
|
||||
} else {
|
||||
newJobsList.add(job);
|
||||
getIt<NavigationService>().showSnackBar(SnackBar(
|
||||
content: Text('jobs.jobAdded'.tr()),
|
||||
duration: const Duration(seconds: 2),
|
||||
));
|
||||
getIt<NavigationService>().showSnackBar('jobs.jobAdded'.tr());
|
||||
emit(JobsStateWithJobs(newJobsList));
|
||||
}
|
||||
}
|
||||
|
@ -70,10 +66,7 @@ class JobsCubit extends Cubit<JobsState> {
|
|||
var isExistInJobList = newJobsList.any((el) => el is CreateSSHKeyJob);
|
||||
if (!isExistInJobList) {
|
||||
newJobsList.add(job);
|
||||
getIt<NavigationService>().showSnackBar(SnackBar(
|
||||
content: Text('jobs.jobAdded'.tr()),
|
||||
duration: const Duration(seconds: 2),
|
||||
));
|
||||
getIt<NavigationService>().showSnackBar('jobs.jobAdded'.tr());
|
||||
emit(JobsStateWithJobs(newJobsList));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:selfprivacy/config/brand_colors.dart';
|
||||
import 'package:selfprivacy/config/text_themes.dart';
|
||||
|
||||
class NavigationService {
|
||||
final GlobalKey<ScaffoldMessengerState> scaffoldMessengerKey =
|
||||
|
@ -17,9 +19,13 @@ class NavigationService {
|
|||
);
|
||||
}
|
||||
|
||||
void showSnackBar(SnackBar snackBar) {
|
||||
void showSnackBar(String text) {
|
||||
final state = scaffoldMessengerKey.currentState!;
|
||||
|
||||
state.showSnackBar(snackBar);
|
||||
final snack = SnackBar(
|
||||
backgroundColor: BrandColors.black.withOpacity(0.8),
|
||||
content: Text(text, style: buttonTitleText),
|
||||
duration: const Duration(seconds: 2),
|
||||
);
|
||||
state.showSnackBar(snack);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,14 +24,14 @@ class SSHModel {
|
|||
await _box.put(BNames.sshPublicKey, savedPubKey);
|
||||
}
|
||||
|
||||
void init() {
|
||||
void init() async {
|
||||
savedPrivateKey = _box.get(BNames.sshPrivateKey);
|
||||
savedPubKey = _box.get(BNames.sshPublicKey);
|
||||
}
|
||||
|
||||
bool get isSSHKeyGenerated => savedPrivateKey != null && savedPubKey != null;
|
||||
|
||||
clear() async {
|
||||
Future<void> clear() async {
|
||||
savedPrivateKey = null;
|
||||
savedPubKey = null;
|
||||
await _box.clear();
|
|
@ -127,7 +127,6 @@ class BrandText extends StatelessWidget {
|
|||
Text build(BuildContext context) {
|
||||
TextStyle style;
|
||||
var isDark = Theme.of(context).brightness == Brightness.dark;
|
||||
|
||||
switch (type) {
|
||||
case TextType.h1:
|
||||
style = isDark
|
||||
|
|
|
@ -119,7 +119,7 @@ class _AppSettingsPageState extends State<AppSettingsPage> {
|
|||
],
|
||||
),
|
||||
),
|
||||
deleteServer(context)
|
||||
// deleteServer(context)
|
||||
],
|
||||
),
|
||||
);
|
||||
|
|
|
@ -5,8 +5,9 @@ import 'package:selfprivacy/config/brand_colors.dart';
|
|||
import 'package:selfprivacy/config/brand_theme.dart';
|
||||
import 'package:selfprivacy/config/get_it_config.dart';
|
||||
import 'package:selfprivacy/config/text_themes.dart';
|
||||
import 'package:selfprivacy/logic/cubit/app_config/app_config_cubit.dart';
|
||||
import 'package:selfprivacy/logic/cubit/jobs/jobs_cubit.dart';
|
||||
import 'package:selfprivacy/logic/get_it/ssh_helper.dart';
|
||||
import 'package:selfprivacy/logic/get_it/ssh.dart';
|
||||
import 'package:selfprivacy/logic/models/job.dart';
|
||||
import 'package:selfprivacy/logic/models/state_types.dart';
|
||||
import 'package:selfprivacy/ui/components/action_button/action_button.dart';
|
||||
|
@ -35,6 +36,7 @@ class MorePage extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var jobsCubit = context.watch<JobsCubit>();
|
||||
var isReady = context.watch<AppConfigCubit>().state.isFullyInitilized;
|
||||
|
||||
return Scaffold(
|
||||
appBar: PreferredSize(
|
||||
|
@ -84,14 +86,16 @@ class MorePage extends StatelessWidget {
|
|||
_MoreMenuTapItem(
|
||||
title: 'more.create_ssh_key'.tr(),
|
||||
iconData: Ionicons.key_outline,
|
||||
onTap: () {
|
||||
onTap: isReady
|
||||
? () {
|
||||
if (getIt<SSHModel>().isSSHKeyGenerated) {
|
||||
showDialog<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return _SSHExitsDetails(
|
||||
onShareTap: () {
|
||||
Share.share(getIt<SSHModel>().savedPrivateKey!);
|
||||
Share.share(
|
||||
getIt<SSHModel>().savedPrivateKey!);
|
||||
},
|
||||
onDeleteTap: () {
|
||||
showDialog(
|
||||
|
@ -99,7 +103,8 @@ class MorePage extends StatelessWidget {
|
|||
builder: (_) {
|
||||
return BrandAlert(
|
||||
title: 'modals.3'.tr(),
|
||||
contentText: 'more.delete_ssh_text'.tr(),
|
||||
contentText:
|
||||
'more.delete_ssh_text'.tr(),
|
||||
acitons: [
|
||||
ActionButton(
|
||||
text: 'more.yes_delete'.tr(),
|
||||
|
@ -118,13 +123,10 @@ class MorePage extends StatelessWidget {
|
|||
},
|
||||
onCopyTap: () {
|
||||
Clipboard.setData(ClipboardData(
|
||||
text: getIt<SSHModel>().savedPrivateKey!));
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('more.copied_ssh'.tr()),
|
||||
duration: const Duration(seconds: 2),
|
||||
),
|
||||
);
|
||||
text: getIt<SSHModel>()
|
||||
.savedPrivateKey!));
|
||||
getIt<NavigationService>()
|
||||
.showSnackBar('more.copied_ssh'.tr());
|
||||
},
|
||||
);
|
||||
},
|
||||
|
@ -137,15 +139,16 @@ class MorePage extends StatelessWidget {
|
|||
title: 'more.create_ssh_key'.tr(),
|
||||
icon: Ionicons.key_outline,
|
||||
onTap: () {
|
||||
jobsCubit
|
||||
.createShhJobIfNotExist(CreateSSHKeyJob());
|
||||
jobsCubit.createShhJobIfNotExist(
|
||||
CreateSSHKeyJob());
|
||||
},
|
||||
text: 'more.generate_key_text'.tr(),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
}
|
||||
: null,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
@ -319,6 +322,7 @@ class _NavItem extends StatelessWidget {
|
|||
child: _MoreMenuItem(
|
||||
iconData: iconData,
|
||||
title: title,
|
||||
isActive: true,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -333,15 +337,14 @@ class _MoreMenuTapItem extends StatelessWidget {
|
|||
}) : super(key: key);
|
||||
|
||||
final IconData iconData;
|
||||
final Function onTap;
|
||||
final VoidCallback? onTap;
|
||||
final String title;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
onTap();
|
||||
},
|
||||
onTap: onTap,
|
||||
child: _MoreMenuItem(
|
||||
isActive: onTap != null,
|
||||
iconData: iconData,
|
||||
title: title,
|
||||
),
|
||||
|
@ -354,10 +357,12 @@ class _MoreMenuItem extends StatelessWidget {
|
|||
Key? key,
|
||||
required this.iconData,
|
||||
required this.title,
|
||||
required this.isActive,
|
||||
}) : super(key: key);
|
||||
|
||||
final IconData iconData;
|
||||
final String title;
|
||||
final bool isActive;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -373,13 +378,19 @@ class _MoreMenuItem extends StatelessWidget {
|
|||
),
|
||||
child: Row(
|
||||
children: [
|
||||
BrandText.body1(title),
|
||||
BrandText.body1(
|
||||
title,
|
||||
style: TextStyle(
|
||||
color: isActive ? null : Colors.grey,
|
||||
),
|
||||
),
|
||||
Spacer(),
|
||||
SizedBox(
|
||||
width: 56,
|
||||
child: Icon(
|
||||
iconData,
|
||||
size: 20,
|
||||
color: isActive ? null : Colors.grey,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
|
Loading…
Reference in a new issue