2021-03-26 13:38:39 +00:00
|
|
|
import 'package:cubit_form/cubit_form.dart';
|
2022-05-18 10:39:11 +00:00
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
2021-03-26 13:38:39 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:selfprivacy/config/brand_colors.dart';
|
|
|
|
import 'package:selfprivacy/config/brand_theme.dart';
|
2021-04-10 03:04:23 +00:00
|
|
|
import 'package:selfprivacy/logic/common_enum/common_enum.dart';
|
|
|
|
import 'package:selfprivacy/logic/cubit/hetzner_metrics/hetzner_metrics_cubit.dart';
|
2021-03-26 13:38:39 +00:00
|
|
|
import 'package:selfprivacy/logic/cubit/server_detailed_info/server_detailed_info_cubit.dart';
|
2022-05-18 10:39:11 +00:00
|
|
|
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
2021-03-26 13:38:39 +00:00
|
|
|
import 'package:selfprivacy/logic/models/state_types.dart';
|
|
|
|
import 'package:selfprivacy/ui/components/brand_divider/brand_divider.dart';
|
2022-01-25 17:00:47 +00:00
|
|
|
import 'package:selfprivacy/ui/components/brand_header/brand_header.dart';
|
2021-03-26 13:38:39 +00:00
|
|
|
import 'package:selfprivacy/ui/components/brand_icons/brand_icons.dart';
|
2022-02-08 21:01:08 +00:00
|
|
|
import 'package:selfprivacy/ui/components/brand_loader/brand_loader.dart';
|
2021-04-10 03:04:23 +00:00
|
|
|
import 'package:selfprivacy/ui/components/brand_radio_tile/brand_radio_tile.dart';
|
2021-03-26 13:38:39 +00:00
|
|
|
import 'package:selfprivacy/ui/components/brand_text/brand_text.dart';
|
|
|
|
import 'package:selfprivacy/ui/components/icon_status_mask/icon_status_mask.dart';
|
|
|
|
import 'package:selfprivacy/ui/components/switch_block/switch_bloc.dart';
|
2022-02-07 07:53:13 +00:00
|
|
|
import 'package:selfprivacy/ui/pages/server_details/time_zone/lang.dart';
|
2022-05-18 10:39:11 +00:00
|
|
|
import 'package:selfprivacy/utils/extensions/duration.dart';
|
2021-03-26 13:38:39 +00:00
|
|
|
import 'package:selfprivacy/utils/named_font_weight.dart';
|
2022-01-25 17:00:47 +00:00
|
|
|
import 'package:selfprivacy/utils/route_transitions/basic.dart';
|
|
|
|
import 'package:timezone/timezone.dart';
|
2022-05-18 10:39:11 +00:00
|
|
|
|
2022-06-05 22:40:34 +00:00
|
|
|
import 'package:selfprivacy/ui/pages/server_details/cpu_chart.dart';
|
|
|
|
import 'package:selfprivacy/ui/pages/server_details/network_charts.dart';
|
2021-03-26 13:38:39 +00:00
|
|
|
|
2021-04-10 03:04:23 +00:00
|
|
|
part 'chart.dart';
|
|
|
|
part 'header.dart';
|
2022-05-18 10:39:11 +00:00
|
|
|
part 'server_settings.dart';
|
|
|
|
part 'text_details.dart';
|
2022-02-07 07:53:13 +00:00
|
|
|
part 'time_zone/time_zone.dart';
|
2021-03-26 13:38:39 +00:00
|
|
|
|
|
|
|
var navigatorKey = GlobalKey<NavigatorState>();
|
|
|
|
|
2022-05-18 10:39:11 +00:00
|
|
|
class ServerDetailsScreen extends StatefulWidget {
|
2022-06-05 22:40:34 +00:00
|
|
|
const ServerDetailsScreen({final super.key});
|
2021-03-26 13:38:39 +00:00
|
|
|
|
|
|
|
@override
|
2022-05-25 12:21:56 +00:00
|
|
|
State<ServerDetailsScreen> createState() => _ServerDetailsScreenState();
|
2021-03-26 13:38:39 +00:00
|
|
|
}
|
|
|
|
|
2022-05-18 10:39:11 +00:00
|
|
|
class _ServerDetailsScreenState extends State<ServerDetailsScreen>
|
2021-03-26 13:38:39 +00:00
|
|
|
with SingleTickerProviderStateMixin {
|
|
|
|
late TabController tabController;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
tabController.dispose();
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
tabController = TabController(length: 2, vsync: this);
|
|
|
|
tabController.addListener(() {
|
|
|
|
setState(() {});
|
|
|
|
});
|
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
2022-06-05 22:40:34 +00:00
|
|
|
Widget build(final BuildContext context) {
|
|
|
|
final bool isReady = context.watch<ServerInstallationCubit>().state
|
2022-05-17 13:31:34 +00:00
|
|
|
is ServerInstallationFinished;
|
2022-06-05 22:40:34 +00:00
|
|
|
final providerState = isReady ? StateType.stable : StateType.uninitialized;
|
2021-03-26 13:38:39 +00:00
|
|
|
|
2022-02-08 21:01:08 +00:00
|
|
|
return BlocProvider(
|
2022-06-05 22:40:34 +00:00
|
|
|
create: (final context) => ServerDetailsCubit()..check(),
|
2022-02-08 21:01:08 +00:00
|
|
|
child: Scaffold(
|
|
|
|
appBar: PreferredSize(
|
2022-05-24 18:55:39 +00:00
|
|
|
preferredSize: const Size.fromHeight(52),
|
2022-02-08 21:01:08 +00:00
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
height: 51,
|
|
|
|
alignment: Alignment.center,
|
2022-05-24 18:55:39 +00:00
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 15),
|
2022-02-08 21:01:08 +00:00
|
|
|
child: BrandText.h4('basis.details'.tr()),
|
|
|
|
),
|
2022-05-24 18:55:39 +00:00
|
|
|
const BrandDivider(),
|
2022-02-08 21:01:08 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
body: TabBarView(
|
2022-05-24 18:55:39 +00:00
|
|
|
physics: const NeverScrollableScrollPhysics(),
|
2022-02-08 21:01:08 +00:00
|
|
|
controller: tabController,
|
2021-06-08 18:52:44 +00:00
|
|
|
children: [
|
2022-02-08 21:01:08 +00:00
|
|
|
SingleChildScrollView(
|
2022-05-24 18:55:39 +00:00
|
|
|
physics: const ClampingScrollPhysics(),
|
2022-02-08 21:01:08 +00:00
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Padding(
|
|
|
|
padding: paddingH15V0,
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
_Header(
|
2022-06-05 22:40:34 +00:00
|
|
|
providerState: providerState,
|
|
|
|
tabController: tabController,
|
|
|
|
),
|
2022-02-08 21:01:08 +00:00
|
|
|
BrandText.body1('providers.server.bottom_sheet.1'.tr()),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
2022-05-24 18:55:39 +00:00
|
|
|
const SizedBox(height: 10),
|
2022-02-08 21:01:08 +00:00
|
|
|
BlocProvider(
|
2022-06-05 22:40:34 +00:00
|
|
|
create: (final context) => HetznerMetricsCubit()..restart(),
|
|
|
|
child: _Chart(),
|
2022-02-08 21:01:08 +00:00
|
|
|
),
|
2022-05-24 18:55:39 +00:00
|
|
|
const SizedBox(height: 20),
|
2022-06-05 22:40:34 +00:00
|
|
|
_TextDetails(),
|
2022-02-08 21:01:08 +00:00
|
|
|
],
|
|
|
|
),
|
2021-06-08 18:52:44 +00:00
|
|
|
),
|
2022-02-08 21:01:08 +00:00
|
|
|
_ServerSettings(tabController: tabController),
|
2021-06-08 18:52:44 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
2021-03-26 13:38:39 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|