Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kev/805_Place_Random_Seed_Above_Partition #806

Merged
merged 2 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/settings/widgets/section_dataset_toggles.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';

import 'package:markdown_tooltip/markdown_tooltip.dart';
import 'package:rattle/settings/widgets/section_partition.dart';
import 'package:rattle/settings/widgets/section_random_seed.dart';
import 'package:shared_preferences/shared_preferences.dart';

import 'package:rattle/constants/spacing.dart';
Expand Down Expand Up @@ -252,6 +253,10 @@ class DatasetToggles extends ConsumerWidget {
],
),
settingsGroupGap,
RandomSeed(),

settingsGroupGap,

Partition(),
settingsGroupGap,

Expand Down
61 changes: 30 additions & 31 deletions lib/settings/widgets/section_random_seed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class RandomSeed extends ConsumerWidget {
children: [
Row(
children: [
// Title.

MarkdownTooltip(
message: '''

Expand All @@ -76,47 +78,20 @@ class RandomSeed extends ConsumerWidget {
child: const Text(
'Random Seed',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
),
configRowGap,
MarkdownTooltip(
message: '''

**Reset Random Seed:**
Clicking this button resets the random seed to the default value of 42.
This is useful if you want to restore the initial random state.

''',
child: ElevatedButton(
onPressed: () {
ref.read(randomSeedSettingProvider.notifier).state = 42;
_saveRandomSeed(42);

ref
.read(
randomPartitionSettingProvider.notifier,
)
.state = false;
_saveRandomPartition(false);
},
child: const Text('Reset'),
),
),
],
),
configRowGap,
Row(
children: [
RandomSeedRow(
randomSeed: randomSeed,
updateSeed: (newSeed) {
ref.read(randomSeedSettingProvider.notifier).state = newSeed;
_saveRandomSeed(newSeed);
},
),
configRowGap,

MarkdownTooltip(
message: '''

Expand All @@ -128,6 +103,8 @@ class RandomSeed extends ConsumerWidget {
style: TextStyle(fontSize: 16),
),
),
configRowGap,

MarkdownTooltip(
message: '''

Expand All @@ -148,10 +125,32 @@ class RandomSeed extends ConsumerWidget {
},
),
),
configRowGap,
MarkdownTooltip(
message: '''

**Reset Random Seed:**
Clicking this button resets the random seed to the default value of 42.
This is useful if you want to restore the initial random state.

''',
child: ElevatedButton(
onPressed: () {
ref.read(randomSeedSettingProvider.notifier).state = 42;
_saveRandomSeed(42);

ref
.read(
randomPartitionSettingProvider.notifier,
)
.state = false;
_saveRandomPartition(false);
},
child: const Text('Reset'),
),
),
],
),
settingsGroupGap,
const Divider(),
],
);
}
Expand Down
2 changes: 0 additions & 2 deletions lib/settings/widgets/settings_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import 'package:shared_preferences/shared_preferences.dart';

import 'package:rattle/settings/widgets/section_dataset_toggles.dart';
import 'package:rattle/settings/widgets/section_graphic_theme.dart';
import 'package:rattle/settings/widgets/section_random_seed.dart';
import 'package:rattle/settings/widgets/section_session.dart';
import 'package:rattle/providers/cleanse.dart';
import 'package:rattle/providers/keep_in_sync.dart';
Expand Down Expand Up @@ -179,7 +178,6 @@ class SettingsDialogState extends ConsumerState<SettingsDialog> {
Divider(),
DatasetToggles(),
GraphicTheme(),
RandomSeed(),
Session(),
Script(),
],
Expand Down
Loading