Skip to content

Commit 5b111ed

Browse files
committed
done solve cards page
1 parent b3815e4 commit 5b111ed

File tree

8 files changed

+304
-23
lines changed

8 files changed

+304
-23
lines changed

lib/src/lang/en_US.dart

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
const Map<String, String> en_US = {
22
'helloWord': 'Hello World',
3+
'today': 'Today is',
4+
'overview': 'Overview',
5+
'work': 'Work',
6+
'love': 'Love',
7+
'finance': 'Finance',
8+
'solveCards': 'Solve Cards',
39
};

lib/src/lang/vi_VN.dart

+8-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
1-
const Map<String, String> vi_VN = {};
1+
const Map<String, String> vi_VN = {
2+
'today': 'Today is',
3+
'overview': 'Tổng quan',
4+
'work': 'Công việc',
5+
'love': 'Tình yêu',
6+
'finance': 'Tài chính',
7+
'solveCards': 'Giải bài',
8+
};

lib/src/pages/home/details_page.dart

+204
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:flutter_getx_template/src/public/constant.dart';
3+
import 'package:flutter_getx_template/src/public/styles.dart';
4+
import 'package:get/get.dart';
5+
import 'package:translator/translator.dart';
6+
7+
class DetailsPage extends StatefulWidget {
8+
final results;
9+
DetailsPage({this.results});
10+
@override
11+
State<StatefulWidget> createState() => _DetailsPageState();
12+
}
13+
14+
class _DetailsPageState extends State<DetailsPage> {
15+
final translator = GoogleTranslator();
16+
17+
var value1;
18+
var value2;
19+
var value3;
20+
var value4;
21+
bool loading = true;
22+
23+
void initContent() async {
24+
value1 = await translator.translate(
25+
widget.results[0]['meanings']['light'].join('\n\n'),
26+
to: 'vi',
27+
);
28+
print(value1);
29+
value2 = await translator.translate(
30+
widget.results[1]['meanings']['light'].join('\n\n'),
31+
to: 'vi',
32+
);
33+
value3 = await translator.translate(
34+
widget.results[2]['meanings']['light'].join('\n\n'),
35+
to: 'vi',
36+
);
37+
value4 = await translator
38+
.translate(
39+
widget.results[3]['meanings']['light'].join('\n\n'),
40+
to: 'vi',
41+
)
42+
.then((result) {
43+
setState(() {
44+
loading = false;
45+
});
46+
return result;
47+
});
48+
}
49+
50+
@override
51+
void initState() {
52+
super.initState();
53+
initContent();
54+
}
55+
56+
@override
57+
Widget build(BuildContext context) {
58+
return Scaffold(
59+
appBar: AppBar(
60+
backgroundColor: colorBlack,
61+
elevation: 4.0,
62+
centerTitle: true,
63+
title: Text(
64+
'solveCards'.trArgs(),
65+
style: TextStyle(
66+
color: mCL,
67+
fontFamily: 'Lato',
68+
fontSize: width / 20.0,
69+
fontWeight: FontWeight.w600,
70+
),
71+
),
72+
actions: [
73+
GestureDetector(
74+
onTap: () {
75+
if (Get.locale == Locale('vi', 'VN')) {
76+
Get.updateLocale(Locale('en', 'US'));
77+
} else {
78+
Get.updateLocale(Locale('vi', 'VN'));
79+
}
80+
},
81+
child: Container(
82+
padding: EdgeInsets.symmetric(horizontal: 16.0, vertical: 2.0),
83+
margin: EdgeInsets.symmetric(vertical: 1.0),
84+
decoration: BoxDecoration(
85+
color: Colors.transparent,
86+
borderRadius: BorderRadius.circular(8.0),
87+
),
88+
alignment: Alignment.center,
89+
child: Text(
90+
Get.locale == Locale('vi', 'VN') ? 'vi' : 'en',
91+
style: TextStyle(
92+
color: colorPrimary,
93+
fontFamily: 'Lato',
94+
fontSize: width / 22.5,
95+
fontWeight: FontWeight.w600,
96+
),
97+
),
98+
),
99+
),
100+
SizedBox(width: 8.0),
101+
],
102+
),
103+
body: loading
104+
? Container(
105+
color: colorBlack,
106+
height: height,
107+
width: width,
108+
child: Center(
109+
child: CircularProgressIndicator(),
110+
),
111+
)
112+
: Container(
113+
color: colorBlack,
114+
height: height,
115+
width: width,
116+
padding: EdgeInsets.symmetric(horizontal: 20.0),
117+
child: SingleChildScrollView(
118+
physics: ClampingScrollPhysics(),
119+
child: Column(
120+
crossAxisAlignment: CrossAxisAlignment.start,
121+
children: [
122+
SizedBox(height: 20.0),
123+
_buildTitle('overview'.trArgs(), widget.results[0]['name']),
124+
SizedBox(height: 16.0),
125+
Get.locale == Locale('vi', 'VN')
126+
? _buildContentTranslate(value1)
127+
: _buildContent(widget.results[0]['meanings']['light']),
128+
SizedBox(height: 16.0),
129+
_buildTitle('work'.trArgs(), widget.results[1]['name']),
130+
SizedBox(height: 16.0),
131+
Get.locale == Locale('vi', 'VN')
132+
? _buildContentTranslate(value2)
133+
: _buildContent(widget.results[1]['meanings']['light']),
134+
SizedBox(height: 16.0),
135+
_buildTitle('love'.trArgs(), widget.results[2]['name']),
136+
SizedBox(height: 16.0),
137+
Get.locale == Locale('vi', 'VN')
138+
? _buildContentTranslate(value3)
139+
: _buildContent(widget.results[2]['meanings']['light']),
140+
SizedBox(height: 16.0),
141+
_buildTitle('finance'.trArgs(), widget.results[3]['name']),
142+
SizedBox(height: 16.0),
143+
Get.locale == Locale('vi', 'VN')
144+
? _buildContentTranslate(value4)
145+
: _buildContent(widget.results[3]['meanings']['light']),
146+
SizedBox(height: 32.0),
147+
],
148+
),
149+
),
150+
),
151+
);
152+
}
153+
154+
Widget _buildTitle(title, value) {
155+
return RichText(
156+
text: TextSpan(
157+
children: [
158+
TextSpan(
159+
text: title + ':\t\t',
160+
style: TextStyle(
161+
color: colorPrimary,
162+
fontFamily: 'Lato',
163+
fontSize: width / 22.5,
164+
fontWeight: FontWeight.w600,
165+
),
166+
),
167+
TextSpan(
168+
text: value,
169+
style: TextStyle(
170+
color: mCL,
171+
fontFamily: 'Lato',
172+
fontSize: width / 23.0,
173+
fontWeight: FontWeight.w600,
174+
),
175+
),
176+
],
177+
),
178+
);
179+
}
180+
181+
Widget _buildContent(List content) {
182+
return Text(
183+
content.join('\n\n'),
184+
style: TextStyle(
185+
color: mCL,
186+
fontFamily: 'Lato',
187+
fontSize: width / 25.0,
188+
fontWeight: FontWeight.w400,
189+
),
190+
);
191+
}
192+
193+
Widget _buildContentTranslate(future) {
194+
return Text(
195+
future.toString(),
196+
style: TextStyle(
197+
color: mCL,
198+
fontFamily: 'Lato',
199+
fontSize: width / 25.0,
200+
fontWeight: FontWeight.w400,
201+
),
202+
);
203+
}
204+
}

lib/src/pages/home/home_page.dart

+55-22
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import 'package:flip_card/flip_card.dart';
22
import 'package:flutter/material.dart';
33
import 'package:flutter_getx_template/data/tarot_json.dart';
4+
import 'package:flutter_getx_template/src/public/constant.dart';
45
import 'package:flutter_getx_template/src/public/styles.dart';
6+
import 'package:flutter_getx_template/src/routes/app_pages.dart';
57
import 'package:flutter_icons/flutter_icons.dart';
68
import 'package:flutter_neumorphic/flutter_neumorphic.dart';
79
import 'package:intl/intl.dart';
810
import 'package:lottie/lottie.dart';
9-
import '../../public/constant.dart';
10-
import '../../public/styles.dart';
11+
import 'package:get/get.dart';
1112

1213
class HomePage extends StatefulWidget {
1314
@override
@@ -35,58 +36,90 @@ class _HomePageState extends State<HomePage> {
3536
@override
3637
Widget build(BuildContext context) {
3738
return Scaffold(
39+
appBar: AppBar(
40+
backgroundColor: colorBlack,
41+
elevation: .0,
42+
centerTitle: true,
43+
title: Text(
44+
'today'.trArgs() + ' ' + format.format(DateTime.now()),
45+
style: TextStyle(
46+
color: mCL,
47+
fontFamily: 'Lato',
48+
fontSize: width / 20.0,
49+
fontWeight: FontWeight.w600,
50+
),
51+
),
52+
actions: [
53+
GestureDetector(
54+
onTap: () {
55+
if (Get.locale == Locale('vi', 'VN')) {
56+
Get.updateLocale(Locale('en', 'US'));
57+
} else {
58+
Get.updateLocale(Locale('vi', 'VN'));
59+
}
60+
},
61+
child: Container(
62+
padding: EdgeInsets.symmetric(horizontal: 16.0, vertical: 2.0),
63+
margin: EdgeInsets.symmetric(vertical: 1.0),
64+
decoration: BoxDecoration(
65+
color: Colors.transparent,
66+
borderRadius: BorderRadius.circular(8.0),
67+
),
68+
alignment: Alignment.center,
69+
child: Text(
70+
Get.locale == Locale('vi', 'VN') ? 'vi' : 'en',
71+
style: TextStyle(
72+
color: colorPrimary,
73+
fontFamily: 'Lato',
74+
fontSize: width / 22.5,
75+
fontWeight: FontWeight.w600,
76+
),
77+
),
78+
),
79+
),
80+
SizedBox(width: 8.0),
81+
],
82+
),
3883
body: Container(
3984
color: colorBlack,
4085
height: height,
4186
width: width,
4287
child: Column(
4388
crossAxisAlignment: CrossAxisAlignment.center,
4489
children: [
45-
SizedBox(height: height / 15.0),
46-
Text(
47-
'Today is ${format.format(DateTime.now())}',
48-
style: TextStyle(
49-
fontSize: width / 18.0,
50-
fontWeight: FontWeight.w600,
51-
fontFamily: 'Lato',
52-
letterSpacing: 1.5,
53-
wordSpacing: 1.5,
54-
color: mC,
55-
),
56-
textAlign: TextAlign.center,
57-
),
58-
SizedBox(height: 24.0),
90+
SizedBox(height: 12.0),
5991
Container(
6092
child: Column(
6193
children: [
6294
Row(
6395
mainAxisAlignment: MainAxisAlignment.center,
6496
children: [
65-
_buildTarotCard(cardKey1, 0, 'Tổng quan'),
97+
_buildTarotCard(cardKey1, 0, 'overview'.trArgs()),
6698
SizedBox(width: 16.0),
67-
_buildTarotCard(cardKey2, 1, 'Công việc'),
99+
_buildTarotCard(cardKey2, 1, 'work'.trArgs()),
68100
],
69101
),
70102
SizedBox(height: 16.0),
71103
Row(
72104
mainAxisAlignment: MainAxisAlignment.center,
73105
children: [
74-
_buildTarotCard(cardKey3, 2, 'Tình yêu'),
106+
_buildTarotCard(cardKey3, 2, 'love'.trArgs()),
75107
SizedBox(width: 16.0),
76-
_buildTarotCard(cardKey4, 3, 'Tài chính'),
108+
_buildTarotCard(cardKey4, 3, 'finance'.trArgs()),
77109
],
78110
),
79111
SizedBox(height: 30.0),
80112
flips.contains(false)
81113
? Container()
82114
: NeumorphicButton(
83-
onPressed: () => null,
115+
onPressed: () => Get.toNamed(Routes.DETAILS,
116+
arguments: unLockCard.sublist(0, 4)),
84117
margin: EdgeInsets.symmetric(horizontal: 48.0),
85118
child: Row(
86119
mainAxisAlignment: MainAxisAlignment.center,
87120
children: [
88121
Text(
89-
'Giải bài',
122+
'solveCards'.trArgs(),
90123
style: TextStyle(
91124
color: colorPrimary,
92125
fontFamily: 'Lato',

lib/src/routes/app_pages.dart

+8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:flutter_getx_template/src/app.dart';
2+
import 'package:flutter_getx_template/src/pages/home/details_page.dart';
23
import 'package:get/get.dart';
34
part 'app_routes.dart';
45

@@ -12,5 +13,12 @@ class AppPages {
1213
page: () => App(),
1314
children: [],
1415
),
16+
GetPage(
17+
name: Routes.DETAILS,
18+
page: () => DetailsPage(
19+
results: Get.arguments,
20+
),
21+
children: [],
22+
),
1523
];
1624
}

lib/src/routes/app_routes.dart

+1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ part of 'app_pages.dart';
33
abstract class Routes {
44
static const ROOT = '/root';
55
static const HOME = '/home';
6+
static const DETAILS = '/details';
67
}

0 commit comments

Comments
 (0)