official_theme_grid.dart
2.63 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
import 'package:flutter/material.dart';
import '../models/watch_theme_models.dart';
import 'watch_theme_character_avatar.dart';
import 'watch_theme_colors.dart';
import 'watch_theme_selected_view.dart';
import 'watch_theme_section_card.dart';
class OfficialThemeGrid extends StatelessWidget {
const OfficialThemeGrid({
super.key,
required this.themes,
required this.activeThemeId,
required this.onThemeTap,
});
final List<WatchThemeItem> themes;
final int? activeThemeId;
final ValueChanged<int> onThemeTap;
@override
Widget build(BuildContext context) {
return WatchThemeSectionCard(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const WatchThemeSectionTitle('官方主题'),
SizedBox(height: 22),
themes.isEmpty
? SizedBox(
height: 114,
)
:
GridView.builder(
shrinkWrap: true,
padding: EdgeInsets.zero,
physics: const NeverScrollableScrollPhysics(),
itemCount: themes.length,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
mainAxisSpacing: 21,
crossAxisSpacing: 19,
mainAxisExtent: 114,
),
itemBuilder: (context, index) {
final theme = themes[index];
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () => onThemeTap(index),
child: Column(
children: [
WatchThemeSelectedView(
selected: theme.id != null && theme.id == activeThemeId,
size: 88,
child: WatchThemeCharacterAvatar(
size: 88,
assetPath: theme.infoList.firstOrNull?.assetPath,
imageUrl: theme.infoList.firstOrNull?.imgUrl,
),
),
SizedBox(height: 8),
Text(
theme.title,
textAlign: TextAlign.center,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: WatchThemeColors.textPrimary,
fontSize: 12,
fontWeight: FontWeight.w400,
height: 1.25,
),
),
],
),
);
},
),
],
),
);
}
}