Skip to content
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
10 changes: 10 additions & 0 deletions lib/const/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,16 @@ class Settings {
destructiveForeground: Color(0xfffafafa),
);

// Semantic accents for settings tile icons. Each hue follows the meaning of
// its setting (never the violet action hue, which is reserved for
// commands/selection).
static const Color settingsAgentAccent = Color(0xff5da37e); // team markers
static const Color settingsAbilityAccent = Color(0xff6aa1d8); // utility
static const Color settingsNeutralAccent = Color(0xffa1a1aa); // greys toggle
static const Color settingsPersistenceAccent = Color(0xff4b8f86); // saving
static const Color settingsDiscordAccent = Color(0xff5865f2); // brand blurple
static const Color settingsMapAccent = Color(0xffb27c40); // map layers

static const cardForegroundBackdrop = BoxShadow(
color: Colors.black54, // High opacity because the background is dark
blurRadius: 12,
Expand Down
34 changes: 2 additions & 32 deletions lib/interactive_map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,9 @@ import 'package:icarus/widgets/lineup_control_buttons.dart';
import 'package:icarus/widgets/page_transition_overlay.dart';
import 'package:icarus/widgets/image_drop_target.dart';
import 'package:icarus/widgets/line_up_placer.dart';
import 'package:icarus/widgets/map_svg_color_mapper.dart';
import 'package:shadcn_ui/shadcn_ui.dart';

class _MapSvgColorMapper extends ColorMapper {
const _MapSvgColorMapper(this.replacements);

final Map<int, Color> replacements;

@override
Color substitute(
String? id,
String elementName,
String attributeName,
Color color,
) {
final opaqueColorValue = (color.toARGB32() & 0x00FFFFFF) | 0xFF000000;
final replacement = replacements[opaqueColorValue];
if (replacement == null) {
return color;
}
// Keep per-element opacity from the original SVG.
final alpha = (color.a * 255.0).round().clamp(0, 255);
return replacement.withAlpha(alpha);
}
}

class InteractiveMap extends ConsumerStatefulWidget {
const InteractiveMap({
super.key,
Expand All @@ -58,10 +36,6 @@ class InteractiveMap extends ConsumerStatefulWidget {
}

class _InteractiveMapState extends ConsumerState<InteractiveMap> {
static const Color _mapBaseSourceColor = Color(0xFF271406);
static const Color _mapDetailSourceColor = Color(0xFFB27C40);
static const Color _mapHighlightSourceColor = Color(0xFFF08234);

final controller = TransformationController();
Size? _lastViewportSize;
Size? _lastPlayAreaSize;
Expand Down Expand Up @@ -153,11 +127,7 @@ class _InteractiveMapState extends ConsumerState<InteractiveMap> {
),
);
final effectivePalette = ref.watch(effectiveMapThemePaletteProvider);
final mapColorMapper = _MapSvgColorMapper({
_mapBaseSourceColor.toARGB32(): effectivePalette.baseColor,
_mapDetailSourceColor.toARGB32(): effectivePalette.detailColor,
_mapHighlightSourceColor.toARGB32(): effectivePalette.highlightColor,
});
final mapColorMapper = MapSvgColorMapper.forPalette(effectivePalette);

String assetName =
'assets/maps/${Maps.mapNames[ref.watch(mapProvider).currentMap]}_map${isAttack ? "" : "_defense"}.svg';
Expand Down
19 changes: 12 additions & 7 deletions lib/providers/user_preferences_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ class AppPreferences extends HiveObject {
drawingThickness: drawingThickness ?? this.drawingThickness,
discordPresenceEnabled:
discordPresenceEnabled ?? this.discordPresenceEnabled,
videoExportStepDurationSeconds: videoExportStepDurationSeconds ??
this.videoExportStepDurationSeconds,
videoExportStepDurationSeconds:
videoExportStepDurationSeconds ?? this.videoExportStepDurationSeconds,
);
}
}
Expand Down Expand Up @@ -390,36 +390,41 @@ class MapThemeProfilesProvider extends Notifier<MapThemeProfilesState> {
return profile;
}

Future<void> renameProfile({
/// Returns false when nothing was written (unknown or built-in profile,
/// or an empty name) so callers never report a success that didn't happen.
Future<bool> renameProfile({
required String profileId,
required String newName,
}) async {
final profile = _findProfile(profileId);
if (profile == null || profile.isBuiltIn) {
return;
return false;
}
final trimmed = newName.trim();
if (trimmed.isEmpty) {
return;
return false;
}
final updated = profile.copyWith(name: trimmed);
await Hive.box<MapThemeProfile>(HiveBoxNames.mapThemeProfilesBox)
.put(updated.id, updated);
await refreshFromHive();
return true;
}

Future<void> updateProfilePalette({
/// Returns false when nothing was written (unknown or built-in profile).
Future<bool> updateProfilePalette({
required String profileId,
required MapThemePalette palette,
}) async {
final profile = _findProfile(profileId);
if (profile == null || profile.isBuiltIn) {
return;
return false;
}
final updated = profile.copyWith(palette: palette);
await Hive.box<MapThemeProfile>(HiveBoxNames.mapThemeProfilesBox)
.put(updated.id, updated);
await refreshFromHive();
return true;
}

Future<void> deleteProfile(String profileId) async {
Expand Down
29 changes: 2 additions & 27 deletions lib/screenshot/screenshot_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,10 @@ import 'package:icarus/providers/strategy_settings_provider.dart';
import 'package:icarus/providers/text_provider.dart';
import 'package:icarus/providers/utility_provider.dart';
import 'package:icarus/widgets/dot_painter.dart';
import 'package:icarus/widgets/map_svg_color_mapper.dart';
import 'package:icarus/widgets/draggable_widgets/placed_widget_builder.dart';
import 'package:icarus/widgets/drawing_painter.dart';

class _MapSvgColorMapper extends ColorMapper {
const _MapSvgColorMapper(this.replacements);

final Map<int, Color> replacements;

@override
Color substitute(
String? id,
String elementName,
String attributeName,
Color color,
) {
final opaqueColorValue = (color.toARGB32() & 0x00FFFFFF) | 0xFF000000;
final replacement = replacements[opaqueColorValue];
if (replacement == null) {
return color;
}
final alpha = (color.a * 255.0).round().clamp(0, 255);
return replacement.withAlpha(alpha);
}
}

class ScreenshotView extends ConsumerWidget {
ScreenshotView({
super.key,
Expand Down Expand Up @@ -129,11 +108,7 @@ class ScreenshotView extends ConsumerWidget {
String ultOrbsAssetName =
'assets/maps/${Maps.mapNames[ref.watch(mapProvider).currentMap]}_ult_orbs.svg';
final effectivePalette = ref.watch(effectiveMapThemePaletteProvider);
final mapColorMapper = _MapSvgColorMapper({
0xFF271406: effectivePalette.baseColor,
0xFFB27C40: effectivePalette.detailColor,
0xFFF08234: effectivePalette.highlightColor,
});
final mapColorMapper = MapSvgColorMapper.forPalette(effectivePalette);
final mapWidth = CoordinateSystem.screenShotSize.height *
CoordinateSystem.instance.mapAspectRatio;
final mapLeft = (CoordinateSystem.screenShotSize.width - mapWidth) / 2;
Expand Down
Loading
Loading