Skip to content

Commit

Permalink
Split widgets in others files
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineLemelin committed Jul 4, 2024
1 parent c199ad7 commit 831c2d0
Show file tree
Hide file tree
Showing 32 changed files with 1,193 additions and 1,016 deletions.
167 changes: 53 additions & 114 deletions lib/features/app/error/outage/outage_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,131 +3,70 @@ import 'package:flutter/material.dart';

// Package imports:
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:notredame/features/app/error/outage/widgets/outage_build_image.dart';
import 'package:notredame/features/app/error/outage/widgets/outage_build_social_media.dart';
import 'package:stacked/stacked.dart';

// Project imports:
import 'package:notredame/constants/urls.dart';
import 'package:notredame/utils/utils.dart';
import 'package:notredame/features/app/error/outage/outage_viewmodel.dart';
import 'package:notredame/utils/app_theme.dart';

class OutageView extends StatelessWidget {
@override
Widget build(BuildContext context) => ViewModelBuilder<
OutageViewModel>.nonReactive(
viewModelBuilder: () => OutageViewModel(),
builder: (context, model, child) => Scaffold(
backgroundColor: Utils.getColorByBrightness(
context, AppTheme.etsLightRed, AppTheme.primaryDark),
body: Stack(
children: [
SafeArea(
minimum: const EdgeInsets.all(20),
child: Column(
children: <Widget>[
SizedBox(
height: model.getImagePlacement(context),
),
Hero(
tag: 'ets_logo',
child: Image.asset(
"assets/animations/outage.gif",
excludeFromSemantics: true,
width: 500,
color:
Theme.of(context).brightness == Brightness.light
? Colors.white
: AppTheme.etsLightRed,
)),
const SizedBox(
height: 15,
),
SizedBox(height: model.getTextPlacement(context)),
Text(
AppIntl.of(context)!.service_outage,
textAlign: TextAlign.center,
style:
const TextStyle(fontSize: 18, color: Colors.white),
),
SizedBox(height: model.getButtonPlacement(context)),
ElevatedButton(
onPressed: () {
model.tapRefreshButton(context);
},
child: Text(
AppIntl.of(context)!.service_outage_refresh,
style: const TextStyle(fontSize: 17),
),
),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
SizedBox(
height: model.getContactTextPlacement(context),
child: Text(
AppIntl.of(context)!.service_outage_contact,
textAlign: TextAlign.center,
style: const TextStyle(color: Colors.white),
),
Widget build(BuildContext context) =>
ViewModelBuilder<OutageViewModel>.nonReactive(
viewModelBuilder: () => OutageViewModel(),
builder: (context, model, child) => Scaffold(
backgroundColor: Utils.getColorByBrightness(
context, AppTheme.etsLightRed, AppTheme.primaryDark),
body: Stack(
children: [
SafeArea(
minimum: const EdgeInsets.all(20),
child: Column(
children: <Widget>[
SizedBox(
height: model.getImagePlacement(context),
),
outageImageSection(context),
SizedBox(height: model.getTextPlacement(context)),
Text(
AppIntl.of(context)!.service_outage,
textAlign: TextAlign.center,
style: const TextStyle(
fontSize: 18, color: Colors.white),
),
SizedBox(height: model.getButtonPlacement(context)),
ElevatedButton(
onPressed: () {
model.tapRefreshButton(context);
},
child: Text(
AppIntl.of(context)!.service_outage_refresh,
style: const TextStyle(fontSize: 17),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
IconButton(
icon: const FaIcon(
FontAwesomeIcons.earthAmericas,
color: Colors.white,
),
onPressed: () => Utils.launchURL(
Urls.clubWebsite,
AppIntl.of(context)!)),
IconButton(
icon: const FaIcon(
FontAwesomeIcons.github,
color: Colors.white,
),
onPressed: () => Utils.launchURL(
Urls.clubGithub, AppIntl.of(context)!)),
IconButton(
icon: const FaIcon(
Icons.mail_outline,
color: Colors.white,
),
onPressed: () => Utils.launchURL(
Urls.clubEmail, AppIntl.of(context)!)),
IconButton(
icon: const FaIcon(
FontAwesomeIcons.discord,
color: Colors.white,
),
onPressed: () => Utils.launchURL(
Urls.clubDiscord,
AppIntl.of(context)!)),
],
),
],
),
Expanded(
child: outageSocialSection(model, context),
),
],
),
),
SafeArea(
child: Align(
alignment: Alignment.topRight,
child: GestureDetector(
onTap: () => model.triggerTap(context),
child: Container(
width: 60,
height: 60,
color: Colors.transparent,
),
),
),
],
),
)
],
),
SafeArea(
child: Align(
alignment: Alignment.topRight,
child: GestureDetector(
onTap: () => model.triggerTap(context),
child: Container(
width: 60,
height: 60,
color: Colors.transparent,
),
),
),
)
],
),
));
));
}
4 changes: 2 additions & 2 deletions lib/features/app/error/outage/outage_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ class OutageViewModel extends BaseViewModel {
}

double getTextPlacement(BuildContext context) {
return MediaQuery.of(context).size.height * 0.20;
return MediaQuery.of(context).size.height * 0.15;
}

double getButtonPlacement(BuildContext context) {
return MediaQuery.of(context).size.height * 0.08;
}

double getContactTextPlacement(BuildContext context) {
return MediaQuery.of(context).size.height * 0.04;
return MediaQuery.of(context).size.height * 0.10;
}

void tapRefreshButton(BuildContext context) {
Expand Down
15 changes: 15 additions & 0 deletions lib/features/app/error/outage/widgets/outage_build_image.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import 'package:flutter/material.dart';
import 'package:notredame/utils/app_theme.dart';

Widget outageImageSection(BuildContext context) {
return Hero(
tag: 'ets_logo',
child: Image.asset(
"assets/animations/outage.gif",
excludeFromSemantics: true,
width: 500,
color: Theme.of(context).brightness == Brightness.light
? Colors.white
: AppTheme.etsLightRed,
));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:notredame/constants/urls.dart';
import 'package:notredame/features/app/error/outage/outage_viewmodel.dart';
import 'package:notredame/utils/utils.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

Widget outageSocialSection(OutageViewModel model, BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
SizedBox(
height: model.getContactTextPlacement(context),
child: Text(
AppIntl.of(context)!.service_outage_contact,
textAlign: TextAlign.center,
style: const TextStyle(color: Colors.white),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
IconButton(
icon: const FaIcon(
FontAwesomeIcons.earthAmericas,
color: Colors.white,
),
onPressed: () =>
Utils.launchURL(Urls.clubWebsite, AppIntl.of(context)!)),
IconButton(
icon: const FaIcon(
FontAwesomeIcons.github,
color: Colors.white,
),
onPressed: () =>
Utils.launchURL(Urls.clubGithub, AppIntl.of(context)!)),
IconButton(
icon: const FaIcon(
Icons.mail_outline,
color: Colors.white,
),
onPressed: () =>
Utils.launchURL(Urls.clubEmail, AppIntl.of(context)!)),
IconButton(
icon: const FaIcon(
FontAwesomeIcons.discord,
color: Colors.white,
),
onPressed: () =>
Utils.launchURL(Urls.clubDiscord, AppIntl.of(context)!)),
],
),
],
);
}
Loading

0 comments on commit 831c2d0

Please sign in to comment.