-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathabv_strength_helper.dart
More file actions
53 lines (49 loc) · 1.52 KB
/
Copy pathabv_strength_helper.dart
File metadata and controls
53 lines (49 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import 'package:flutter/material.dart';
/// Helper class for getting ABV strength-related information
///
/// Provides consistent ABV strength indicators (colors and labels).
class ABVStrengthHelper {
ABVStrengthHelper._();
/// Get color for ABV strength indicator
///
/// Returns theme-aware colors:
/// - Low ABV (< 4.0%): Blue
/// - Medium ABV (4.0% - 6.9%): Amber
/// - High ABV (>= 7.0%): Deep Orange
static Color getABVColor(BuildContext context, double abv) {
final theme = Theme.of(context);
final colorScheme = theme.colorScheme;
final brightness = theme.brightness;
if (abv < 4.0) {
// Low ABV: Blue-ish
return brightness == Brightness.dark
? colorScheme.primary.withValues(alpha: 0.7)
: colorScheme.primary;
} else if (abv < 7.0) {
// Medium ABV: Amber/Secondary
return brightness == Brightness.dark
? colorScheme.secondary.withValues(alpha: 0.8)
: colorScheme.secondary;
} else {
// High ABV: Deep Orange/Tertiary
return brightness == Brightness.dark
? const Color(0xFFFF5722).withValues(alpha: 0.85)
: const Color(0xFFE64A19);
}
}
/// Get human-readable label for ABV strength
///
/// Returns:
/// - "(Low)" for ABV < 4.0%
/// - "(Medium)" for ABV 4.0% - 6.9%
/// - "(High)" for ABV >= 7.0%
static String getABVStrengthLabel(double abv) {
if (abv < 4.0) {
return '(Low)';
} else if (abv < 7.0) {
return '(Medium)';
} else {
return '(High)';
}
}
}