Skip to content

Commit e8390cb

Browse files
committed
Added task box containing a button and the task
1 parent 70303c4 commit e8390cb

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

lib/code_judge_task_box.dart

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import 'package:flutter/material.dart';
2+
3+
class CodeJudgeTaskBox extends StatelessWidget{
4+
final Widget child;
5+
final String task;
6+
final VoidCallback? onButtonPressed;
7+
final bool showButton;
8+
final IconData? buttonIcon;
9+
10+
const CodeJudgeTaskBox({
11+
super.key,
12+
required this.child,
13+
required this.task,
14+
this.onButtonPressed,
15+
this.showButton = false,
16+
this.buttonIcon,
17+
});
18+
19+
@override
20+
Widget build(BuildContext context) {
21+
final theme = Theme.of(context);
22+
23+
return Expanded(
24+
child: SingleChildScrollView(
25+
padding: const EdgeInsets.all(16),
26+
child: Column(
27+
children: [
28+
// Draw a nice box containing a button and the task
29+
Container(
30+
width: double.infinity,
31+
padding: const EdgeInsets.all(16),
32+
decoration: BoxDecoration(
33+
color: theme.colorScheme.surfaceContainerHigh,
34+
borderRadius: BorderRadius.circular(12),
35+
border: Border.all(color: theme.colorScheme.outline, width: 1),
36+
),
37+
child: Row(
38+
spacing: 16,
39+
children: [
40+
// Display the task
41+
Expanded(
42+
child: Text(
43+
task,
44+
softWrap: true,
45+
),
46+
),
47+
// Display a button with the correct icon
48+
showButton
49+
? FloatingActionButton.small(
50+
heroTag: "hint",
51+
onPressed: onButtonPressed,
52+
child: Icon(buttonIcon)
53+
)
54+
: SizedBox.shrink(),
55+
],
56+
),
57+
),
58+
// Display the child
59+
child,
60+
],
61+
),
62+
),
63+
);
64+
}
65+
}

0 commit comments

Comments
 (0)