-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.dart
153 lines (142 loc) · 5.12 KB
/
main.dart
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
import 'package:research_package/research_package.dart';
import 'package:cognition_package/cognition_package.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:carp_serializable/carp_serializable.dart';
import 'package:flutter/services.dart';
part 'cognition_config.dart';
part 'cognition_page.dart';
part 'user_demographics_page.dart';
Future main() async {
// Initialize cognition package.
// Needed if you load a cognition configurations from a json file
CognitionPackage.ensureInitialized();
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
supportedLocales: const [
Locale('en'),
Locale('da'),
Locale('fr'),
Locale('pt'),
],
localizationsDelegates: [
// Research Package (RP) and Cognition Package (CP) translations.
// Supports translation of both the RP and CP specific text as well as
// app-specific text.
// Read more about localization at https://carp.cachet.dk/localization/
RPLocalizations.delegate,
CPLocalizations.delegate,
// Built-in localization of basic text for Cupertino widgets
GlobalCupertinoLocalizations.delegate,
// Built-in localization of basic text for Material widgets
GlobalMaterialLocalizations.delegate,
// Built-in localization for text direction LTR/RTL
GlobalWidgetsLocalizations.delegate,
],
// Returns a locale which will be used by the app
localeResolutionCallback: (locale, supportedLocales) {
// Check if the current device locale is supported
for (var supportedLocale in supportedLocales) {
if (supportedLocale.languageCode == locale!.languageCode) {
return supportedLocale;
}
}
// if the locale of the device is not supported, use the first one
// from the list (English, in this case).
return supportedLocales.first;
},
theme: ThemeData.light(),
darkTheme: ThemeData.dark(),
title: 'Cognition Package Demo',
home: const MyHomePage(),
debugShowCheckedModeBanner: false,
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@override
MyHomePageState createState() => MyHomePageState();
}
class MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
var locale = RPLocalizations.of(context);
return Scaffold(
backgroundColor: const Color(0xff003F6E),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(height: 50),
Padding(
padding: const EdgeInsets.all(22.0),
child: Image.asset(
"assets/images/mcat-logo.png",
height: 80,
),
),
Padding(
padding:
const EdgeInsets.symmetric(vertical: 20, horizontal: 25),
child: Column(
children: <Widget>[
Text(
locale?.translate("home.welcome") ?? "Welcome",
textAlign: TextAlign.center,
style: const TextStyle(fontSize: 16, color: Colors.white),
),
Container(height: 5),
Text(
locale?.translate("home.questions") ?? "Questions?",
textAlign: TextAlign.center,
style: const TextStyle(fontSize: 16, color: Colors.white),
),
Container(height: 5),
const Text(
"support@carp.dk",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 16,
color: Colors.white,
decoration: TextDecoration.underline),
),
//Container(height: 50),
],
)),
Padding(
padding: const EdgeInsets.only(top: 50),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xffC32C39),
fixedSize: const Size(300, 60),
),
child: Text(
locale?.translate("home.start") ?? "Get started",
style: const TextStyle(fontSize: 18, color: Colors.white),
),
onPressed: () {
Navigator.of(context).push(MaterialPageRoute<dynamic>(
builder: (context) => const CognitionPage()));
},
),
),
],
),
),
bottomNavigationBar: SafeArea(
child: Padding(
padding: const EdgeInsets.all(22.0),
child: Image.asset(
"assets/images/carp_logo.png",
height: 50,
),
)),
);
}
}