Skip to content

Commit 18abac0

Browse files
Merge pull request #17 from OctagonalStar/feat/wordcard-view
Feat/wordcard view
2 parents 81a7eeb + 176feca commit 18abac0

File tree

6 files changed

+236
-106
lines changed

6 files changed

+236
-106
lines changed

lib/funcs/ui.dart

Lines changed: 64 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -412,78 +412,78 @@ class WordCard extends StatelessWidget {
412412
Widget build(BuildContext context) {
413413
MediaQueryData mediaQuery = MediaQuery.of(context);
414414
bool hide = useMask;
415-
return Container(
416-
margin: const EdgeInsets.all(16.0),
417-
//padding: const EdgeInsets.all(16.0),
418-
width: width ?? (mediaQuery.size.width * 0.9),
419-
height: height ?? (mediaQuery.size.height * 0.5),
420-
decoration: BoxDecoration(
421-
color: Theme.of(context).colorScheme.onInverseSurface.withAlpha(150),
422-
borderRadius: StaticsVar.br,
423-
),
424-
child: Column(
425-
mainAxisAlignment: MainAxisAlignment.start,
426-
children: [
427-
ElevatedButton.icon(
428-
style: ElevatedButton.styleFrom(
429-
fixedSize: Size(width ?? (mediaQuery.size.width * 0.9), height == null ? (mediaQuery.size.height * 0.2) : height! * 0.4),
430-
backgroundColor: Theme.of(context).colorScheme.onPrimary.withAlpha(150),
431-
shape: RoundedRectangleBorder(borderRadius: StaticsVar.br),
432-
padding: const EdgeInsets.all(16.0),
433-
),
434-
icon: const Icon(Icons.volume_up, size: 24.0),
435-
label: FittedBox(child: Text(word["arabic"], style: TextStyle(fontSize: 64.0, fontFamily: context.read<Global>().arFont))),
436-
onPressed: (){
437-
playTextToSpeech(word["arabic"], context);
438-
},
415+
double useWidth = width ?? mediaQuery.size.width * 0.9;
416+
double useHeight = height ?? mediaQuery.size.height * 0.5;
417+
return Column(
418+
mainAxisAlignment: MainAxisAlignment.start,
419+
children: [
420+
ElevatedButton.icon(
421+
style: ElevatedButton.styleFrom(
422+
fixedSize: Size(useWidth, useHeight * 0.3),
423+
backgroundColor: Theme.of(context).colorScheme.onPrimary.withAlpha(150),
424+
shape: RoundedRectangleBorder(borderRadius: BorderRadiusGeometry.vertical(top: Radius.circular(25.0))),
425+
padding: const EdgeInsets.all(16.0),
439426
),
440-
Stack(
441-
children: [
442-
Center(
427+
icon: const Icon(Icons.volume_up, size: 24.0),
428+
label: FittedBox(child: Text(word["arabic"], style: TextStyle(fontSize: 64.0, fontFamily: context.read<Global>().arFont))),
429+
onPressed: (){
430+
playTextToSpeech(word["arabic"], context);
431+
},
432+
),
433+
Stack(
434+
children: [
435+
Container(
436+
width: useWidth,
437+
height: useHeight * 0.6,
438+
decoration: BoxDecoration(
439+
color: Theme.of(context).colorScheme.onInverseSurface.withAlpha(150),
440+
borderRadius: BorderRadius.vertical(bottom: Radius.circular(25.0)),
441+
),
442+
child: Center(
443443
child: Text(' 中文:${word["chinese"]}\n 示例:${word["explanation"]}\n 归属课程:${word["subClass"]}',
444444
style: Theme.of(context).textTheme.bodyLarge,
445445
textAlign: TextAlign.left,
446446
),
447447
),
448-
StatefulBuilder(
449-
builder: (context, setLocalState) {
450-
return TweenAnimationBuilder<double>(
451-
tween: Tween(
452-
begin: 1.0,
453-
end: hide ? 1.0 : 0.0
454-
),
455-
duration: Duration(milliseconds: 500),
456-
curve: StaticsVar.curve,
457-
builder: (context, value, child) {
458-
return ClipRRect(
459-
borderRadius: BorderRadiusGeometry.vertical(bottom: Radius.circular(25.0)),
460-
child: BackdropFilter(
461-
filter: ImageFilter.blur(sigmaX: 10.0 * value,sigmaY: 10.0 * value),
462-
enabled: true,
463-
child: value == 0.0 ? null : ElevatedButton(
464-
style: ElevatedButton.styleFrom(
465-
fixedSize: Size(width ?? (mediaQuery.size.width * 0.9), height == null ? (mediaQuery.size.height * 0.3) : height! * 0.6),
466-
backgroundColor: Colors.transparent,
467-
shape: RoundedRectangleBorder(borderRadius: BorderRadiusGeometry.vertical(bottom: Radius.circular(25.0)))
468-
),
469-
onPressed: (){
470-
setLocalState(() {
471-
hide = false;
472-
},);
473-
},
474-
child: hide ? Text("点此查看释义") : SizedBox()
448+
),
449+
StatefulBuilder(
450+
builder: (context, setLocalState) {
451+
return TweenAnimationBuilder<double>(
452+
tween: Tween(
453+
begin: 1.0,
454+
end: hide ? 1.0 : 0.0
455+
),
456+
duration: Duration(milliseconds: 500),
457+
curve: StaticsVar.curve,
458+
builder: (context, value, child) {
459+
return ClipRRect(
460+
borderRadius: BorderRadiusGeometry.vertical(bottom: Radius.circular(25.0)),
461+
child: BackdropFilter(
462+
filter: ImageFilter.blur(sigmaX: 10.0 * value,sigmaY: 10.0 * value),
463+
enabled: true,
464+
child: value == 0.0 ? null : ElevatedButton(
465+
style: ElevatedButton.styleFrom(
466+
fixedSize: Size(useWidth, useHeight * 0.6),
467+
backgroundColor: Colors.transparent,
468+
shadowColor: Colors.transparent,
469+
shape: RoundedRectangleBorder(borderRadius: BorderRadiusGeometry.vertical(bottom: Radius.circular(25.0)))
475470
),
471+
onPressed: (){
472+
setLocalState(() {
473+
hide = false;
474+
},);
475+
},
476+
child: hide ? Text("点此查看释义") : SizedBox()
476477
),
477-
);
478-
},
479-
);
480-
}
481-
)
482-
],
483-
)
484-
485-
],
486-
)
478+
),
479+
);
480+
},
481+
);
482+
}
483+
)
484+
],
485+
)
486+
],
487487
);
488488
}
489489
}

lib/main.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ class _MyHomePageState extends State<MyHomePage> {
102102
children: [
103103
// 侧边导航栏
104104
NavigationRail(
105+
minWidth: MediaQuery.of(context).size.width * 0.05,
105106
selectedIndex: currentIndex,
106107
onDestinationSelected: (int index) {
107108
_onNavigationTapped(index);

lib/pages/home_page.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ class HomePage extends StatelessWidget {
2323
mainAxisAlignment: MainAxisAlignment.center,
2424
children: [
2525
Container(
26-
width: mediaQuery.size.width * 0.32,
26+
width: mediaQuery.size.width * 0.30,
2727
height: mediaQuery.size.height * 0.18,
28-
margin: EdgeInsets.all(8.0),
28+
margin: EdgeInsets.all(4.0),
2929
padding: EdgeInsets.all(16.0),
3030
decoration: BoxDecoration(
3131
color: themeColor.secondaryContainer.withAlpha(150),
@@ -56,9 +56,9 @@ class HomePage extends StatelessWidget {
5656
),
5757
),
5858
Container(
59-
width: mediaQuery.size.width * 0.56,
59+
width: mediaQuery.size.width * 0.50,
6060
height: mediaQuery.size.height * 0.18,
61-
margin: EdgeInsets.all(8.0),
61+
margin: EdgeInsets.all(4.0),
6262
padding: EdgeInsets.all(16.0),
6363
decoration: BoxDecoration(
6464
color: themeColor.secondaryContainer.withAlpha(150),
@@ -86,9 +86,9 @@ class HomePage extends StatelessWidget {
8686
mainAxisAlignment: MainAxisAlignment.center,
8787
children: [
8888
Container(
89-
width: mediaQuery.size.width * 0.54,
89+
width: mediaQuery.size.width * 0.50,
9090
height: mediaQuery.size.height * 0.18,
91-
margin: EdgeInsets.all(8.0),
91+
margin: EdgeInsets.all(4.0),
9292
decoration: BoxDecoration(
9393
borderRadius: BorderRadius.circular(25.0),
9494
),
@@ -114,9 +114,9 @@ class HomePage extends StatelessWidget {
114114
),
115115
),
116116
Container(
117-
width: mediaQuery.size.width * 0.34,
117+
width: mediaQuery.size.width * 0.35,
118118
height: mediaQuery.size.height * 0.18,
119-
margin: EdgeInsets.all(8.0),
119+
margin: EdgeInsets.all(4.0),
120120
decoration: BoxDecoration(
121121
borderRadius: BorderRadius.circular(25.0),
122122
),

lib/pages/learning_page.dart

Lines changed: 53 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,62 @@ class LearningPage extends StatelessWidget {
1717
child: Column(
1818
mainAxisAlignment: MainAxisAlignment.start,
1919
children: [
20-
ElevatedButton(
21-
style: ElevatedButton.styleFrom(
22-
backgroundColor: Theme.of(context).colorScheme.onPrimary.withAlpha(150),
23-
shadowColor: Colors.transparent,
24-
fixedSize: Size(mediaQuery.size.width * 0.9, mediaQuery.size.height * 0.2),
25-
shape: RoundedRectangleBorder(
26-
borderRadius: BorderRadiusGeometry.vertical(bottom: Radius.circular(25.0)),
27-
),
28-
),
29-
onPressed: () {
30-
shiftToStudy(context, 0);
31-
},
32-
child: Container(
33-
width: mediaQuery.size.width * 0.9,
34-
height: mediaQuery.size.height * 0.2,
35-
alignment: Alignment.center,
36-
child: Column(
37-
mainAxisAlignment: MainAxisAlignment.center,
38-
children: [
39-
Icon(Icons.sync_alt, size: 24.0),
40-
Text(
41-
'中阿混合学习',
42-
style: TextStyle(fontSize: 40.0, fontWeight: FontWeight.bold),
20+
Row(
21+
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
22+
children: [
23+
ElevatedButton(
24+
style: ElevatedButton.styleFrom(
25+
backgroundColor: Theme.of(context).colorScheme.onPrimary.withAlpha(150),
26+
shadowColor: Colors.transparent,
27+
fixedSize: Size(mediaQuery.size.width * 0.5, mediaQuery.size.height * 0.2),
28+
shape: RoundedRectangleBorder(
29+
borderRadius: BorderRadiusGeometry.vertical(bottom: Radius.circular(25.0)),
4330
),
44-
SizedBox(height: mediaQuery.size.height * 0.01),
45-
Text(
46-
'还有${(context.read<Global>().wordCount - context.read<Global>().settingData["learning"]["KnownWords"].length).toString()}个单词待学习~',
47-
style: TextStyle(fontSize: 12.0),
31+
),
32+
onPressed: () {
33+
shiftToStudy(context, 0);
34+
},
35+
child: FittedBox(
36+
child: Column(
37+
mainAxisAlignment: MainAxisAlignment.center,
38+
children: [
39+
Icon(Icons.sync_alt, size: 24.0),
40+
Text(
41+
'中阿混合学习',
42+
style: TextStyle(fontSize: 40.0, fontWeight: FontWeight.bold),
43+
),
44+
],
4845
),
49-
],
46+
),
5047
),
51-
),
48+
ElevatedButton(
49+
style: ElevatedButton.styleFrom(
50+
backgroundColor: Theme.of(context).colorScheme.onPrimary.withAlpha(150),
51+
shadowColor: Colors.transparent,
52+
fixedSize: Size(mediaQuery.size.width * 0.35, mediaQuery.size.height * 0.2),
53+
shape: RoundedRectangleBorder(
54+
borderRadius: BorderRadiusGeometry.vertical(bottom: Radius.circular(25.0)),
55+
),
56+
),
57+
onPressed: (){
58+
Navigator.push(
59+
context,
60+
MaterialPageRoute(
61+
builder: (context) => WordCardOverViewPage()
62+
)
63+
);
64+
},
65+
child: FittedBox(
66+
child: Column(
67+
mainAxisAlignment: MainAxisAlignment.center,
68+
children: [
69+
Icon(Icons.abc, size: 24),
70+
Text("词汇总览", style: TextStyle(fontSize: 40.0, fontWeight: FontWeight.bold)),
71+
],
72+
),
73+
),
74+
)
75+
],
5276
),
5377
SizedBox(height: mediaQuery.size.height * 0.01),
5478
Row(

lib/pages/test_page.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class TestPage extends StatelessWidget {
5454
),
5555
ElevatedButton.icon(
5656
icon: Icon(Icons.multitrack_audio, size: 36.0),
57-
label: Text('自主\n听写', style: TextStyle(fontSize: 34.0)),
57+
label: FittedBox(child: Text('自主\n听写', style: TextStyle(fontSize: 34.0))),
5858
style: ElevatedButton.styleFrom(
5959
backgroundColor: Theme.of(context).colorScheme.onPrimary.withAlpha(150),
6060
fixedSize: Size(mediaQuery.size.width * 0.42, mediaQuery.size.height * 0.45,),
@@ -78,9 +78,9 @@ class TestPage extends StatelessWidget {
7878
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
7979
children: [
8080
Container(
81-
width: mediaQuery.size.width * 0.58,
81+
width: mediaQuery.size.width * 0.50,
8282
height: mediaQuery.size.height * 0.16,
83-
margin: EdgeInsets.all(8.0),
83+
margin: EdgeInsets.all(4.0),
8484
decoration: BoxDecoration(
8585
borderRadius: StaticsVar.br,
8686
),
@@ -111,9 +111,9 @@ class TestPage extends StatelessWidget {
111111
),
112112
),
113113
Container(
114-
width: mediaQuery.size.width * 0.32,
114+
width: mediaQuery.size.width * 0.30,
115115
height: mediaQuery.size.height * 0.16,
116-
margin: EdgeInsets.all(8.0),
116+
margin: EdgeInsets.all(4.0),
117117
decoration: BoxDecoration(
118118
borderRadius: StaticsVar.br,
119119
),

0 commit comments

Comments
 (0)