Skip to content

Commit eb951c2

Browse files
committed
universal html
1 parent c2c48ad commit eb951c2

File tree

7 files changed

+96
-40
lines changed

7 files changed

+96
-40
lines changed

lib/components/main_page.dart

+40-33
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import 'package:mcgamejam_website/components/sections/faq_section.dart';
55
import 'package:mcgamejam_website/components/stylized_components.dart';
66

77
class MainContent extends StatelessWidget {
8-
const MainContent({Key? key}) : super(key: key);
8+
final int pageIndex;
9+
10+
const MainContent({Key? key, required this.pageIndex}) : super(key: key);
911

1012
@override
1113
Widget build(BuildContext context) {
@@ -16,11 +18,16 @@ class MainContent extends StatelessWidget {
1618
child: Container(
1719
constraints: const BoxConstraints(maxWidth: 1000),
1820
padding: const EdgeInsets.all(30),
19-
child: Column(
20-
children: const [
21-
AboutSection(),
22-
FaqSection()
23-
])
21+
child: (pageIndex) {
22+
switch (pageIndex) {
23+
case 1:
24+
return const AboutSection();
25+
case 2:
26+
return const FaqSection();
27+
default:
28+
return const Text("Not implemented");
29+
}
30+
}(pageIndex)
2431
)
2532
)
2633
);
@@ -49,33 +56,33 @@ class MainPageState extends State<MainPage> {
4956

5057
@override
5158
Widget build(BuildContext context) {
52-
return PreferredSize(
53-
preferredSize: const Size(1920, 1080),
54-
child: LayoutBuilder(
55-
builder: (BuildContext context, BoxConstraints constraints) {
56-
final isNarrow = constraints.maxWidth < 1000;
57-
if (isNarrow) {
58-
// mobile
59-
return Scaffold(
60-
appBar: AppBar(
61-
title: const McGameJamTitle(),
62-
),
63-
bottomNavigationBar: const NewNavBar(),
64-
body: const MainContent());
65-
} else {
66-
// desktop
67-
return Scaffold(
68-
appBar: AppBar(
69-
title: const McGameJamTitle(),
70-
),
71-
body: Row(
72-
children: [
73-
NewNavRail(),
74-
const Expanded(child: MainContent())
75-
],
76-
));
77-
}
78-
}));
59+
return SafeArea(
60+
child: LayoutBuilder(
61+
builder: (BuildContext context, BoxConstraints constraints) {
62+
final isNarrow = constraints.maxWidth < 1000;
63+
if (isNarrow) {
64+
// mobile
65+
return Scaffold(
66+
appBar: AppBar(
67+
title: const McGameJamTitle(),
68+
),
69+
bottomNavigationBar: const NewNavBar(),
70+
body: MainContent(pageIndex: selectedIndex));
71+
} else {
72+
// desktop
73+
return Scaffold(
74+
appBar: AppBar(
75+
title: const McGameJamTitle(),
76+
),
77+
body: Row(
78+
children: [
79+
const NewNavRail(),
80+
Expanded(child: MainContent(pageIndex: selectedIndex,))
81+
],
82+
));
83+
}
84+
})
85+
);
7986
}
8087

8188
}

lib/components/navigation_bar.dart

+10-4
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,14 @@ class NewNavBarState extends State<NewNavBar> {
3939
}
4040
}
4141

42-
class NewNavRail extends StatelessWidget {
42+
class NewNavRail extends StatefulWidget {
4343
const NewNavRail({super.key});
4444

45+
@override
46+
State<StatefulWidget> createState() => NewNavRailState();
47+
}
48+
49+
class NewNavRailState extends State<NewNavRail> {
4550
@override
4651
Widget build(BuildContext context) {
4752
return NavigationRail(
@@ -60,11 +65,12 @@ class NewNavRail extends StatelessWidget {
6065
MyApp.of(context).locale = Locale.fromSubtags(languageCode: Localizations.localeOf(context).languageCode == 'en' ? 'fr' : 'en');
6166
break;
6267
default:
63-
MainPage.of(context).selectedIndex = index;
68+
setState(() {
69+
MainPage.of(context).selectedIndex = index;
70+
});
6471
break;
6572
}
6673
},
6774
);
6875
}
69-
70-
}
76+
}

lib/l10n/app_en.arb

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"signUpTitle": "Sign Up",
55
"langToggle": "EN/FR",
66
"whatIsMcGameJam": "WHAT IS MCGAMEJAM?",
7-
"mcGameJamDescription": "McGameJam is a 48 hour game development marathon where attendees are tasked with creating a playable game, in any shape or form, based on a chosen thematic. Organized by Game Dev McGill, McGameJam's goal is to bring students together to collaborate and create great games, regardless of their skill level. So whether you are a veteran game developer or a first-time jammer, join us for a weekend of game development, learning, and fun.",
7+
"mcGameJamDescription": "McGameJam is a 48 hour game development marathon where attendees are tasked with creating a playable game, in any shape or form, based on a chosen thematic. Organized by GameDevMcGill, McGameJam's goal is to bring students together to collaborate and create great games, regardless of their skill level. So whether you are a veteran game developer or a first-time jammer, join us for a weekend of game development, learning, and fun.",
88
"faq": "FAQ",
99
"whenAndWhere": "When and where is it?",
1010
"timeAndLocation": "McGameJam 2024 will be happening between Friday January 19th and Sunday January 21st, in the Trottier building on McGill campus (3630 Rue University, Montreal, QC H3A 0C6)."

lib/l10n/app_fr.arb

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"signUpTitle": "Inscription",
55
"langToggle": "FR/EN",
66
"whatIsMcGameJam": "QU'EST-CE QUE MCGAMEJAM ?",
7-
"mcGameJamDescription": "McGameJam est un marathon de développement de jeux de 48 heures où les participant·e·s sont invité·e·s à créer un jeu, dans toute sa forme, basé sur une thématique choisie. Proposé par Game Dev McGill, McGameJam a pour objectif de rassembler des étudiant·e·s pour collaborer et donner vie à d'excellents jeux, indépendamment de leur expérience. Que vous ayez déjà une longue expérience en développement de jeux ou que vous participiez à un jam pour la première fois, venez passer un week-end de création, d'apprentissage et d'amusement.",
7+
"mcGameJamDescription": "McGameJam est un marathon de développement de jeux de 48 heures où les participant·e·s sont invité·e·s à créer un jeu, dans toute sa forme, basé sur une thématique choisie. Proposé par GameDevMcGill, McGameJam a pour objectif de rassembler des étudiant·e·s pour collaborer et donner vie à d'excellents jeux, indépendamment de leur expérience. Que vous ayez déjà une longue expérience en développement de jeux ou que vous participiez à un jam pour la première fois, venez passer un week-end de création, d'apprentissage et d'amusement.",
88
"faq": "FAQ",
99
"whenAndWhere": "Où et quand ?",
1010
"timeAndLocation": "McGameJam 2024 aura lieu entre vendredi le 19 janvier et dimanche le 21 janvier, sur le campus de McGill au Pavillon Trottier situé au 3630, rue University, Montréal QC H3A 0C6."

lib/main.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import 'package:flutter/material.dart';
33
import 'package:mcgamejam_website/components/main_page.dart';
44
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
5-
import 'dart:html';
5+
import 'package:universal_html/html.dart';
66

77

88
void main() {

pubspec.lock

+42
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ packages:
2222
url: "https://pub.dartlang.org"
2323
source: hosted
2424
version: "1.2.1"
25+
charcode:
26+
dependency: transitive
27+
description:
28+
name: charcode
29+
url: "https://pub.dartlang.org"
30+
source: hosted
31+
version: "1.3.1"
2532
clock:
2633
dependency: transitive
2734
description:
@@ -36,6 +43,13 @@ packages:
3643
url: "https://pub.dartlang.org"
3744
source: hosted
3845
version: "1.16.0"
46+
csslib:
47+
dependency: transitive
48+
description:
49+
name: csslib
50+
url: "https://pub.dartlang.org"
51+
source: hosted
52+
version: "0.17.2"
3953
cupertino_icons:
4054
dependency: "direct main"
4155
description:
@@ -105,6 +119,13 @@ packages:
105119
description: flutter
106120
source: sdk
107121
version: "0.0.0"
122+
html:
123+
dependency: transitive
124+
description:
125+
name: html
126+
url: "https://pub.dartlang.org"
127+
source: hosted
128+
version: "0.15.3"
108129
intl:
109130
dependency: "direct main"
110131
description:
@@ -208,6 +229,27 @@ packages:
208229
url: "https://pub.dartlang.org"
209230
source: hosted
210231
version: "0.4.12"
232+
typed_data:
233+
dependency: transitive
234+
description:
235+
name: typed_data
236+
url: "https://pub.dartlang.org"
237+
source: hosted
238+
version: "1.3.2"
239+
universal_html:
240+
dependency: "direct main"
241+
description:
242+
name: universal_html
243+
url: "https://pub.dartlang.org"
244+
source: hosted
245+
version: "2.2.2"
246+
universal_io:
247+
dependency: transitive
248+
description:
249+
name: universal_io
250+
url: "https://pub.dartlang.org"
251+
source: hosted
252+
version: "2.2.0"
211253
vector_math:
212254
dependency: transitive
213255
description:

pubspec.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ dependencies:
4141
intl: any
4242
ffi: ^2.0.2
4343
firebase_core: ^2.15.0
44+
universal_html: ^2.2.2
4445

4546
dev_dependencies:
4647
flutter_test:

0 commit comments

Comments
 (0)