Skip to content

Commit

Permalink
Christmas countdown
Browse files Browse the repository at this point in the history
  • Loading branch information
Nexerate committed Nov 17, 2024
1 parent cd0938d commit 5e0bcb0
Show file tree
Hide file tree
Showing 9 changed files with 417 additions and 288 deletions.
Binary file added assets/images/christmas_background_dark.webp
Binary file not shown.
8 changes: 4 additions & 4 deletions lib/pages/event/cards/event_card_countdown.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ class EventCardCountdownState extends State<EventCardCountdown> {
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
numberColumn(days, days == 1 ? 'Dag' : 'Dager'),
numberColumn(hours, hours == 1 ? 'Time' : 'Timer'),
numberColumn(minutes, minutes == 1 ? 'Minutt' : 'Minutter'),
numberColumn(seconds, seconds == 1 ? 'Sekund' : 'Sekunder'),
numberColumn(days, 'Dager'),
numberColumn(hours, 'Timer'),
numberColumn(minutes, 'Minutter'),
numberColumn(seconds, 'Sekunder'),
],
),
);
Expand Down
121 changes: 62 additions & 59 deletions lib/pages/games/games_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,65 +14,68 @@ class GamesPage extends ScrollablePage {
Widget content(BuildContext context) {
final padding = MediaQuery.of(context).padding + OnlineTheme.horizontalPadding;

return Padding(
padding: padding + EdgeInsets.symmetric(vertical: 64),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const SizedBox(height: 24),
DrikkeSanger(carouselOptions: getCarouselOptions(context)),
const SizedBox(height: 24),
const SizedBox(height: 24),
Text(
'Spill',
style: OnlineTheme.header(),
textAlign: TextAlign.center,
),
const SizedBox(height: 24),
CarouselSlider(
items: [
GameCard(
name: 'Terning',
imageSource: 'assets/images/diceHeader.jpg',
onTap: () {
context.go('/social/games/dice');
},
),
GameCard(
name: 'Hundre spørsmål',
imageSource: 'assets/images/hundred-questions.png',
onTap: () {
context.go('/social/games/hundred_questions');
},
),
GameCard(
name: 'SpinLine',
imageSource: 'assets/images/SpinLine.png',
onTap: () {
context.go('/social/games/spinline');
},
),
GameCard(
name: 'Roulette',
imageSource: 'assets/images/roulette.png',
onTap: () {
context.go('/social/games/roulette');
// AppNavigator.navigateToPage(const RoulettePage(), withHeaderNavbar: false);
},
),
GameCard(
name: 'Bits',
imageSource: 'assets/images/bits.png',
onTap: () {
context.go('/social/games/bits');
// AppNavigator.navigateToPage(const BitsHomePage(), withHeaderNavbar: false);
},
),
],
options: getCarouselOptions(context),
),
const SizedBox(height: 24),
],
return ClipRect(
child: Container(
color: OnlineTheme.current.bg,
padding: padding + EdgeInsets.symmetric(vertical: 64),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const SizedBox(height: 24),
DrikkeSanger(carouselOptions: getCarouselOptions(context)),
const SizedBox(height: 24),
const SizedBox(height: 24),
Text(
'Spill',
style: OnlineTheme.header(),
textAlign: TextAlign.center,
),
const SizedBox(height: 24),
CarouselSlider(
items: [
GameCard(
name: 'Terning',
imageSource: 'assets/images/diceHeader.jpg',
onTap: () {
context.go('/social/dice');
},
),
GameCard(
name: 'Hundre spørsmål',
imageSource: 'assets/images/hundred-questions.png',
onTap: () {
context.go('/social/hundred_questions');
},
),
GameCard(
name: 'SpinLine',
imageSource: 'assets/images/SpinLine.png',
onTap: () {
context.go('/social/spinline');
},
),
GameCard(
name: 'Roulette',
imageSource: 'assets/images/roulette.png',
onTap: () {
context.go('/social/roulette');
// AppNavigator.navigateToPage(const RoulettePage(), withHeaderNavbar: false);
},
),
GameCard(
name: 'Bits',
imageSource: 'assets/images/bits.png',
onTap: () {
context.go('/social/bits');
// AppNavigator.navigateToPage(const BitsHomePage(), withHeaderNavbar: false);
},
),
],
options: getCarouselOptions(context),
),
const SizedBox(height: 24),
],
),
),
);
}
Expand Down
14 changes: 7 additions & 7 deletions lib/pages/games/songs/songs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,37 +27,37 @@ class DrikkeSanger extends StatelessWidget {
SongCard(
name: 'Lambo',
imageSource: 'assets/images/lambo.jpg',
onTap: () => context.go('/social/songs/lambo'),
onTap: () => context.go('/social/lambo'),
),
SongCard(
name: 'Nu Klinger',
imageSource: 'assets/images/nu_klinger.jpg',
onTap: () => context.go('/social/songs/nu_klinger'),
onTap: () => context.go('/social/nu_klinger'),
),
SongCard(
name: 'Studenter Visen',
imageSource: 'assets/images/studentervisen.png',
onTap: () => context.go('/social/songs/studenter_visen'),
onTap: () => context.go('/social/studenter_visen'),
),
SongCard(
name: 'Kamerater Hev Nu Glasset!',
imageSource: 'assets/images/kameraterhevglasset.png',
onTap: () => context.go('/social/songs/kamerater_hev_glasset'),
onTap: () => context.go('/social/kamerater_hev_glasset'),
),
SongCard(
name: 'Himmelseng',
imageSource: 'assets/images/himmelseng.png',
onTap: () => context.go('/social/songs/himmelseng'),
onTap: () => context.go('/social/himmelseng'),
),
SongCard(
name: 'Fader Abraham',
imageSource: 'assets/images/faderabraham.png',
onTap: () => context.go('/social/songs/fader_abraham'),
onTap: () => context.go('/social/fader_abraham'),
),
SongCard(
name: 'We like to drink with',
imageSource: 'assets/images/we_like_to_drink.png',
onTap: () => context.go('/social/songs/we_like_to_drink'),
onTap: () => context.go('/social/we_like_to_drink'),
),
],
),
Expand Down
127 changes: 127 additions & 0 deletions lib/pages/home/christmas/christmas_countdown.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
import 'dart:async';

import 'package:flutter/material.dart';

import '/pages/event/cards/event_card_countdown.dart';
import '/theme/theme.dart';

class ChristmasCountdown extends StatefulWidget {
const ChristmasCountdown({super.key});

@override
ChristmasCountdownState createState() => ChristmasCountdownState();
}

class ChristmasCountdownState extends State<ChristmasCountdown> {
final ValueNotifier<bool> isChristmas = ValueNotifier<bool>(false);
Timer? _timer;

@override
void initState() {
super.initState();
_startTimer();
}

void _startTimer() {
_timer = Timer.periodic(Duration(seconds: 1), (timer) {
final today = DateTime.now();
final merryChristmas = today.month == 12 && today.day == 24;
isChristmas.value = merryChristmas;
});
}

@override
void dispose() {
_timer?.cancel();
isChristmas.dispose();
super.dispose();
}

Widget _background() {
return Positioned.fill(
child: Image.asset(
'assets/images/christmas_background_dark.webp',
fit: BoxFit.cover,
),
);
}

Widget _merryChristmas() {
return SizedBox(
height: 180,
child: Stack(
children: [
_background(),
Container(
padding: OnlineTheme.horizontalPadding,
decoration: BoxDecoration(
color: OnlineTheme.current.bg.withOpacity(0.6),
border: Border(
bottom: BorderSide(
color: OnlineTheme.current.border,
width: 2,
),
),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Center(
child: Text(
'God Jul!',
style: OnlineTheme.header(),
),
),
],
),
),
],
),
);
}

Widget _christmasCountdown() {
return SizedBox(
height: 180,
child: Stack(
children: [
_background(),
Container(
padding: OnlineTheme.horizontalPadding,
decoration: BoxDecoration(
color: OnlineTheme.current.bg.withOpacity(0.6),
border: Border(
bottom: BorderSide(
color: OnlineTheme.current.border,
width: 2,
),
),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'Hvor lenge er det til Julaften?',
style: OnlineTheme.header(),
),
const SizedBox(height: 24),
EventCardCountdown(eventTime: DateTime(2024, 12, 24)),
],
),
),
],
),
);
}

@override
Widget build(BuildContext context) {
return ValueListenableBuilder<bool>(
valueListenable: isChristmas,
builder: (context, merryChristmas, child) {
return merryChristmas ? _merryChristmas() : _christmasCountdown();
},
);
}
}
Loading

0 comments on commit 5e0bcb0

Please sign in to comment.