-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbrewery_hero_panel.dart
More file actions
95 lines (87 loc) · 3.08 KB
/
Copy pathbrewery_hero_panel.dart
File metadata and controls
95 lines (87 loc) · 3.08 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import 'package:flutter/material.dart';
import '../models/models.dart';
import '../utils/utils.dart';
import 'facts_strip.dart';
/// The identity hero at the top of the brewery screen.
///
/// Presents only the brewery's own facts — name, location, how many drinks and
/// styles it brings to the festival, when it was founded, and its notes — on a
/// plain surface card marked with the category-colour left edge, matching the
/// drink hero and the list card. The [accentCategory] is chosen by the caller
/// (a brewery can span categories) to colour that edge.
class BreweryHeroPanel extends StatelessWidget {
final Producer producer;
/// How many of this brewery's drinks are at the festival.
final int drinkCount;
/// How many distinct styles those drinks span. A zero count hides the cell.
final int styleCount;
/// The category whose accent colours the left edge — the brewery's dominant
/// category, computed by the caller.
final String accentCategory;
const BreweryHeroPanel({
required this.producer,
required this.drinkCount,
required this.styleCount,
required this.accentCategory,
super.key,
});
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final accent = CategoryColorHelper.getAccentColor(
accentCategory,
theme.brightness,
);
final hasNotes = producer.notes != null && producer.notes!.isNotEmpty;
final cells = <FactCell>[
FactCell(label: 'Drinks', value: factValueText(theme, '$drinkCount')),
if (styleCount > 0)
FactCell(label: 'Styles', value: factValueText(theme, '$styleCount')),
if (producer.yearFounded != null)
FactCell(
label: 'Founded',
value: factValueText(theme, '${producer.yearFounded}'),
),
];
return Card(
margin: const EdgeInsets.fromLTRB(16, 12, 16, 4),
clipBehavior: Clip.antiAlias,
child: Container(
decoration: BoxDecoration(
border: Border(left: BorderSide(color: accent, width: 4)),
),
padding: const EdgeInsets.fromLTRB(18, 16, 18, 16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SelectableText(
producer.name,
style: theme.textTheme.headlineSmall?.copyWith(
fontWeight: FontWeight.bold,
),
),
if (producer.location.isNotEmpty) ...[
const SizedBox(height: 6),
SelectableText(
producer.location,
key: const ValueKey('brewery-location'),
style: theme.textTheme.bodyMedium?.copyWith(
color: theme.colorScheme.onSurfaceVariant,
),
),
],
const SizedBox(height: 14),
FactsStrip(cells: cells),
if (hasNotes) ...[
const SizedBox(height: 14),
HeroAboutSection(
heading: 'About this brewery',
body: producer.notes!,
),
],
],
),
),
);
}
}