Skip to content

Commit

Permalink
Merge branch 'PE-6222-add-health-check-option-on-dev-tools-panel' int…
Browse files Browse the repository at this point in the history
…o PE-6281-upload-images-with-thumbnails-with-generator
  • Loading branch information
thiagocarvalhodev committed Jun 24, 2024
2 parents bc5c2dc + cfda4f0 commit 60db794
Show file tree
Hide file tree
Showing 4 changed files with 284 additions and 271 deletions.
195 changes: 101 additions & 94 deletions lib/dev_tools/app_dev_tools.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'dart:convert';
import 'package:ardrive/dev_tools/drives_health_check.dart';
import 'package:ardrive/dev_tools/thumbnail_generator_poc.dart';
import 'package:ardrive/main.dart';
import 'package:ardrive/pages/drive_detail/components/hover_widget.dart';
import 'package:ardrive/services/config/config.dart';
import 'package:ardrive/turbo/topup/blocs/payment_form/payment_form_bloc.dart';
import 'package:ardrive/utils/logger.dart';
Expand Down Expand Up @@ -364,23 +363,6 @@ class AppConfigWindowManagerState extends State<AppConfigWindowManager> {
type: ArDriveDevToolOptionType.bool,
);

final ArDriveDevToolOption fakeTurboCredits = ArDriveDevToolOption<BigInt?>(
name: 'fakeTurboCredits',
value: config.fakeTurboCredits,
onChange: (value) {
late AppConfig newConfig;
if (value == null) {
newConfig = config.copyWith(unsetFakeTurboCredits: true);
} else {
newConfig = config.copyWith(fakeTurboCredits: value);
}
setState(() {
configService.updateAppConfig(newConfig);
});
},
type: ArDriveDevToolOptionType.turboCredits,
);

final ArDriveDevToolOption topUpDryRun = ArDriveDevToolOption(
name: 'topUpDryRun',
value: config.topUpDryRun,
Expand Down Expand Up @@ -412,82 +394,99 @@ class AppConfigWindowManagerState extends State<AppConfigWindowManager> {
autoSyncIntervalInSecondsOption,
turboSetDefaultData,
forceNoFreeThanksToTurbo,
fakeTurboCredits,
topUpDryRun,
reloadOption,
resetOptions,
];

final typography = ArDriveTypographyNew.of(context);

return DraggableWindow(
windowTitle: _windowTitle,
child: SingleChildScrollView(
primary: true,
child: Column(
children: [
const SizedBox(height: 16),
const SizedBox(height: 48),
FutureBuilder(
future: _readConfigsFromEnv(),
builder: (context, snapshot) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
ArDriveButton(
text: 'dev env',
onPressed: () {
setState(() {
_windowTitle.value = 'Reloading...';

configService.updateAppConfig(
AppConfig.fromJson(snapshot.data![0]),
);
});

Future.delayed(const Duration(seconds: 1), () {
setState(() {
_windowTitle.value = 'Dev config';
reloadPage();
});
});
},
),
ArDriveButton(
text: 'staging env',
onPressed: () {
setState(() {
_windowTitle.value = 'Reloading...';

configService.updateAppConfig(
AppConfig.fromJson(snapshot.data![2]),
);
});

Future.delayed(const Duration(seconds: 1), () {
setState(() {
_windowTitle.value = 'Staging config';
reloadPage();
});
});
},
),
ArDriveButton(
text: 'prod env',
onPressed: () {
setState(() {
_windowTitle.value = 'Reloading...';

configService.updateAppConfig(
AppConfig.fromJson(snapshot.data![1]),
);
});

Future.delayed(const Duration(seconds: 1), () {
setState(() {
_windowTitle.value = 'Prod config';
});
});
},
)
],
return Padding(
padding: const EdgeInsets.all(16),
child: Row(
children: [
Flexible(
child: ArDriveButtonNew(
text: 'dev env',
typography: typography,
variant: ButtonVariant.primary,
onPressed: () {
setState(() {
_windowTitle.value = 'Reloading...';

configService.updateAppConfig(
AppConfig.fromJson(snapshot.data![0]),
);
});

Future.delayed(const Duration(seconds: 1), () {
setState(() {
_windowTitle.value = 'Dev config';
reloadPage();
});
});
},
),
),
const SizedBox(width: 16),
Flexible(
child: ArDriveButtonNew(
text: 'staging env',
variant: ButtonVariant.primary,
typography: typography,
onPressed: () {
setState(() {
_windowTitle.value = 'Reloading...';

configService.updateAppConfig(
AppConfig.fromJson(snapshot.data![2]),
);
});

Future.delayed(const Duration(seconds: 1), () {
setState(() {
_windowTitle.value = 'Staging config';
reloadPage();
});
});
},
),
),
const SizedBox(width: 16),
Flexible(
child: ArDriveButtonNew(
text: 'prod env',
variant: ButtonVariant.primary,
typography: typography,
onPressed: () {
setState(() {
_windowTitle.value = 'Reloading...';

configService.updateAppConfig(
AppConfig.fromJson(snapshot.data![1]),
);
});

Future.delayed(const Duration(seconds: 1), () {
setState(() {
_windowTitle.value = 'Prod config';
});
});
},
),
)
],
),
);
}),
ListView.separated(
Expand Down Expand Up @@ -524,7 +523,7 @@ class AppConfigWindowManagerState extends State<AppConfigWindowManager> {
Widget buildOption(ArDriveDevToolOption option) {
switch (option.type) {
case ArDriveDevToolOptionType.text:
return ArDriveTextField(
return ArDriveTextFieldNew(
label: option.name,
initialValue: option.value,
onFieldSubmitted: (value) {
Expand All @@ -542,7 +541,7 @@ class AppConfigWindowManagerState extends State<AppConfigWindowManager> {
},
);
case ArDriveDevToolOptionType.number:
return ArDriveTextField(
return ArDriveTextFieldNew(
label: option.name,
initialValue: option.value.toString(),
onFieldSubmitted: (value) {
Expand All @@ -553,7 +552,9 @@ class AppConfigWindowManagerState extends State<AppConfigWindowManager> {
);

case ArDriveDevToolOptionType.button:
return ArDriveButton(
return ArDriveButtonNew(
variant: ButtonVariant.primary,
typography: ArDriveTypographyNew.of(context),
text: option.name,
onPressed: () {
option.onChange(option.value);
Expand All @@ -562,8 +563,9 @@ class AppConfigWindowManagerState extends State<AppConfigWindowManager> {
);

case ArDriveDevToolOptionType.buttonTertiary:
return ArDriveButton(
style: ArDriveButtonStyle.tertiary,
return ArDriveButtonNew(
variant: ButtonVariant.outline,
typography: ArDriveTypographyNew.of(context),
text: option.name,
onPressed: () => option.onChange(option.value),
);
Expand Down Expand Up @@ -695,16 +697,21 @@ class DraggableWindow extends HookWidget {
),
Align(
alignment: Alignment.topRight,
child: ArDriveIconButton(
icon: ArDriveIcons.closeCircle(
color: ArDriveTheme.of(context)
.themeData
.colors
.themeBgCanvas,
child: Padding(
padding: const EdgeInsets.only(top: 20, right: 8),
child: ArDriveClickArea(
child: GestureDetector(
onTap: () {
ArDriveDevTools().closeDevTools();
},
child: ArDriveIcons.x(
color: ArDriveTheme.of(context)
.themeData
.colorTokens
.iconLow,
),
),
),
onPressed: () {
ArDriveDevTools().closeDevTools();
},
),
),
],
Expand Down
Loading

0 comments on commit 60db794

Please sign in to comment.