Skip to content

Commit ffbd9fb

Browse files
committed
Opportunity to highlight an item
1 parent 0ce38f1 commit ffbd9fb

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

lib/code_judge_list_items.dart

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class CodeJudgeDesktopAndTabletItem extends StatelessWidget{
2323
final ValueChanged<TapUpDetails>? onRightClick;
2424
final ValueChanged<Offset>? onMenuClick;
2525
final String note;
26+
final bool isSelected;
2627

2728
const CodeJudgeDesktopAndTabletItem({
2829
super.key,
@@ -32,6 +33,7 @@ class CodeJudgeDesktopAndTabletItem extends StatelessWidget{
3233
this.onRightClick,
3334
this.onMenuClick,
3435
this.note = "",
36+
this.isSelected = false,
3537
});
3638

3739
@override
@@ -61,7 +63,14 @@ class CodeJudgeDesktopAndTabletItem extends StatelessWidget{
6163
hoverColor: theme.colorScheme.tertiary.withAlpha(32), // Hover-color
6264
child: Container(
6365
alignment: Alignment.center,
64-
child: Stack(
66+
decoration: BoxDecoration(
67+
borderRadius: BorderRadius.circular(12),
68+
border: Border.all( // Highlight a selected item
69+
color: isSelected ? theme.colorScheme.primary : Colors.transparent,
70+
width: 2
71+
),
72+
),
73+
child: Stack( // Draw the content of the item
6574
children: [
6675
Positioned(
6776
top: 2,
@@ -106,6 +115,7 @@ class CodeJudgeMobileItem extends StatelessWidget {
106115
final ValueChanged<TapUpDetails>? onRightClick;
107116
final ValueChanged<Offset>? onMenuClick;
108117
final String note;
118+
final bool isSelected;
109119

110120
const CodeJudgeMobileItem({
111121
super.key,
@@ -115,6 +125,7 @@ class CodeJudgeMobileItem extends StatelessWidget {
115125
this.onRightClick,
116126
this.onMenuClick,
117127
this.note = "",
128+
this.isSelected = false,
118129
});
119130

120131
@override
@@ -145,7 +156,14 @@ class CodeJudgeMobileItem extends StatelessWidget {
145156
child: Container(
146157
padding: const EdgeInsets.all(8.0),
147158
alignment: Alignment.centerLeft,
148-
child: Row(
159+
decoration: BoxDecoration(
160+
borderRadius: BorderRadius.circular(12),
161+
border: Border.all( // Highlight a selected item
162+
color: isSelected ? theme.colorScheme.primary : Colors.transparent,
163+
width: 2
164+
),
165+
),
166+
child: Row( // Draw the content of the item
149167
children: [
150168
Expanded(
151169
child: Padding(

0 commit comments

Comments
 (0)