@@ -8,6 +8,7 @@ import 'package:open_filex/open_filex.dart';
88import 'package:path/path.dart' as p;
99import 'package:trios/about/about_page.dart' ;
1010import 'package:trios/models/mod_variant.dart' ;
11+ import 'package:trios/thirdparty/dartx/iterable.dart' ;
1112import 'package:trios/thirdparty/faded_scrollable/faded_scrollable.dart' ;
1213import 'package:trios/trios/app_state.dart' ;
1314import 'package:trios/trios/constants.dart' ;
@@ -139,6 +140,7 @@ Future<void> showDeleteModFoldersConfirmationDialog(
139140 bool allowDeletingEnabledMods =
140141 allowDeletingEnabledModsDefaultState ?? false ;
141142 List <ModVariant > filteredVariantsToDelete = variantsToDelete;
143+ List <ModVariant > enabledVariantsThatWillNotBeDeleted = [];
142144
143145 final shouldDelete = await showDialog <bool >(
144146 context: context,
@@ -148,14 +150,26 @@ Future<void> showDeleteModFoldersConfirmationDialog(
148150 return StatefulBuilder (
149151 builder: (context, setState) {
150152 final allMods = ref.read (AppState .mods);
151- filteredVariantsToDelete = variantsToDelete
152- .where (
153- (variant) => allowDeletingEnabledMods
154- ? true
155- : ! variant.isEnabled (allMods),
156- )
153+
154+ final isOnlyEnabledMods = variantsToDelete.all (
155+ (variant) => variant.isEnabled (allMods),
156+ );
157+
158+ enabledVariantsThatWillNotBeDeleted =
159+ (isOnlyEnabledMods || allowDeletingEnabledMods)
160+ ? []
161+ : variantsToDelete
162+ .where ((variant) => ! variant.isEnabled (allMods))
163+ .toList ();
164+
165+ filteredVariantsToDelete =
166+ variantsToDelete - enabledVariantsThatWillNotBeDeleted;
167+
168+ final enabledVariants = variantsToDelete
169+ .where ((variant) => variant.isEnabled (allMods))
157170 .toList ();
158- final s = filteredVariantsToDelete.length > 1 ? "s" : "" ;
171+
172+ final s = filteredVariantsToDelete.length == 1 ? "s" : "" ;
159173
160174 return AlertDialog (
161175 title: Text ('Delete Mod$s ' ),
@@ -166,7 +180,9 @@ Future<void> showDeleteModFoldersConfirmationDialog(
166180 crossAxisAlignment: CrossAxisAlignment .start,
167181 spacing: 8 ,
168182 children: [
169- const Text ('Are you sure you want to delete:' ),
183+ if (filteredVariantsToDelete.isNotEmpty ||
184+ isOnlyEnabledMods)
185+ const Text ('Are you sure you want to delete:' ),
170186 Flexible (
171187 child: FadedScrollable (
172188 child: Scrollbar (
@@ -182,47 +198,61 @@ Future<void> showDeleteModFoldersConfirmationDialog(
182198 children: [
183199 for (final variant
184200 in filteredVariantsToDelete)
185- Column (
186- mainAxisSize: MainAxisSize .min,
187- crossAxisAlignment:
188- CrossAxisAlignment .start,
189- children: [
190- Text (
191- "• ${variant .modInfo .nameOrId } v${variant .modInfo .version }" ,
192- style: theme.textTheme.labelLarge,
193- ),
194- Text (
195- " ${variant .modFolder .path }" ,
196- style: theme.textTheme.labelMedium
197- ? .copyWith (
198- color: theme
199- .textTheme
200- .bodyMedium
201- ? .color
202- ? .withAlpha (200 ),
203- ),
201+ _buildVariantToDeleteRow (variant, theme),
202+ if (enabledVariantsThatWillNotBeDeleted
203+ .isNotEmpty)
204+ Padding (
205+ padding: const .only (top: 16 ),
206+ child: Text .rich (
207+ TextSpan (
208+ style: theme.textTheme.bodyLarge
209+ ? .copyWith (fontSize: 20 ),
210+ children: [
211+ TextSpan (
212+ text:
213+ "The following mods will " ,
214+ ),
215+ TextSpan (
216+ text: "not" ,
217+ style: theme
218+ .textTheme
219+ .bodyMedium
220+ ? .copyWith (
221+ fontSize: 20 ,
222+ fontWeight: .bold,
223+ ),
224+ ),
225+ TextSpan (
226+ text:
227+ " be deleted because they are enabled:" ,
228+ ),
229+ ],
204230 ),
205- ] ,
231+ ) ,
206232 ),
233+ for (final variant
234+ in enabledVariantsThatWillNotBeDeleted)
235+ _buildVariantToDeleteRow (variant, theme),
207236 ],
208237 ),
209238 ),
210239 ),
211240 ),
212241 ),
213242 ),
214- CheckboxWithLabel (
215- label: "Allow deleting of currently-enabled mods" ,
216- value: allowDeletingEnabledMods,
217- onChanged: (newValue) {
218- setState (() {
219- allowDeletingEnabledMods =
220- newValue ??
221- allowDeletingEnabledModsDefaultState ??
222- false ;
223- });
224- },
225- ),
243+ if (! isOnlyEnabledMods && enabledVariants.isNotEmpty)
244+ CheckboxWithLabel (
245+ label: "Allow deleting of currently-enabled mods" ,
246+ value: allowDeletingEnabledMods,
247+ onChanged: (newValue) {
248+ setState (() {
249+ allowDeletingEnabledMods =
250+ newValue ??
251+ allowDeletingEnabledModsDefaultState ??
252+ false ;
253+ });
254+ },
255+ ),
226256 Text (
227257 "This will delete the mod folder$s on disk. This action cannot be undone." ,
228258 style: theme.textTheme.bodyMedium? .copyWith (
@@ -267,3 +297,30 @@ Future<void> showDeleteModFoldersConfirmationDialog(
267297 },
268298 );
269299}
300+
301+ Row _buildVariantToDeleteRow (ModVariant variant, ThemeData theme) {
302+ return Row (
303+ children: [
304+ Checkbox (value: true , onChanged: (newValue) {}),
305+ Padding (
306+ padding: const .only (left: 4 ),
307+ child: Column (
308+ mainAxisSize: MainAxisSize .min,
309+ crossAxisAlignment: CrossAxisAlignment .start,
310+ children: [
311+ Text (
312+ "${variant .modInfo .nameOrId } v${variant .modInfo .version }" ,
313+ style: theme.textTheme.labelLarge,
314+ ),
315+ Text (
316+ variant.modFolder.path,
317+ style: theme.textTheme.labelMedium? .copyWith (
318+ color: theme.textTheme.bodyMedium? .color? .withAlpha (200 ),
319+ ),
320+ ),
321+ ],
322+ ),
323+ ),
324+ ],
325+ );
326+ }
0 commit comments