Skip to content

Commit

Permalink
Add studies link #12
Browse files Browse the repository at this point in the history
  • Loading branch information
guyluz11 committed May 1, 2024
1 parent 00f1586 commit 1fdcab5
Show file tree
Hide file tree
Showing 17 changed files with 318 additions and 25 deletions.
5 changes: 4 additions & 1 deletion assets/translations/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,8 @@
"start": "Start",
"analytically": "Analytically",
"creatively": "Creatively",
"undefined": "Undefined"
"undefined": "Undefined",
"studies_link": "Full List",
"all_tips": "All Tips",
"resource_is_empty": "Resource is empty"
}
5 changes: 4 additions & 1 deletion assets/translations/he-IL.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,8 @@
"start": "התחל",
"analytically": "אנליטי",
"creatively": "יצירתי",
"undefined": "לא מוגדר"
"undefined": "לא מוגדר",
"studies_link": "לינק למחקרים",
"all_tips": "כל הטיפים",
"resource_is_empty": "אין מקורות"
}
1 change: 1 addition & 0 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = B8Y5J572KK;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "Infinite Horizons";
Expand Down
7 changes: 6 additions & 1 deletion lib/domain/study_type_abstract.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ enum StudyType {
;

const StudyType(this.previewName);

final String previewName;
}

Expand All @@ -54,7 +55,11 @@ enum EnergyType {
max('max', Duration(minutes: 90)),
;

const EnergyType(this.previewName, this.duration);
const EnergyType(
this.previewName,
this.duration,
);

final Duration duration;
final String previewName;
}
20 changes: 17 additions & 3 deletions lib/domain/tip.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
class Tip {
Tip(this.id, this.text, {this.selected = false});
Tip(
this.id,
this.text, {
this.selected = false,
this.resourceLinks = const [],
});

int id;
String text;
bool selected;
final List<Uri> resourceLinks;
}

List<Tip> tipsList = [
Expand All @@ -12,8 +18,16 @@ List<Tip> tipsList = [
Tip(1, 'Screen/book is being hold in eye level'),

/// Analytical tips
Tip(2, 'Room with low ceiling or hat/hoody'),
Tip(
2,
'Room with low ceiling or hat/hoodie',
resourceLinks: [Uri.parse('https://assets.csom.umn.edu/assets/71190.pdf')],
),

// Creatively tips
Tip(3, 'Environment with high ceiling or outside'),
Tip(
3,
'Environment with high ceiling or outside',
resourceLinks: [Uri.parse('https://assets.csom.umn.edu/assets/71190.pdf')],
),
];
16 changes: 16 additions & 0 deletions lib/presentation/atoms/button_atom.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ class ButtonAtom extends StatelessWidget {
final VoidCallback onPressed;
final String? text;
final IconData? icon;

double get width => 150;

double get _height => 60;
final bool disabled;
final bool translate;
Expand Down Expand Up @@ -101,6 +103,20 @@ class ButtonAtom extends StatelessWidget {
),
);
} else if (variant == ButtonVariant.tertiary) {
if (icon == null) {
return buttonConstraints(
child: FilledButton(
onPressed: onPressed,
style: FilledButton.styleFrom().copyWith(
alignment: Alignment.center,
backgroundColor: disabled
? MaterialStateProperty.all(colorScheme.outline)
: MaterialStateProperty.all(colorScheme.tertiaryContainer),
),
child: label(textTheme),
),
);
}
return buttonConstraints(
child: FilledButton.icon(
onPressed: onPressed,
Expand Down
21 changes: 13 additions & 8 deletions lib/presentation/organisms/intro/tips_organism.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:infinite_horizons/domain/study_type_abstract.dart';
import 'package:infinite_horizons/domain/tip.dart';
import 'package:infinite_horizons/presentation/atoms/atoms.dart';
import 'package:infinite_horizons/presentation/pages/all_tips.dart';

class TipsOrganism extends StatelessWidget {
void onCheckBox(int id, bool value) =>
Expand All @@ -25,13 +25,18 @@ class TipsOrganism extends StatelessWidget {
},
itemCount: StudyTypeAbstract.instance!.getTips().length,
),
// TODO: Add full list page
// const Row(
// mainAxisAlignment: MainAxisAlignment.end,
// children: [
// TextAtom('Full list'),
// ],
// ),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
ButtonAtom(
variant: ButtonVariant.tertiary,
onPressed: () => Navigator.of(context).push(
MaterialPageRoute(builder: (context) => AllTips()),
),
text: 'studies_link',
),
],
),
],
);
}
Expand Down
1 change: 1 addition & 0 deletions lib/presentation/organisms/organisms.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export 'package:infinite_horizons/presentation/organisms/intro/motivation_organi
export 'package:infinite_horizons/presentation/organisms/intro/tips_organism.dart';
export 'package:infinite_horizons/presentation/organisms/intro/welcome_organism.dart';
export 'package:infinite_horizons/presentation/organisms/timer_molecule.dart';
export 'package:infinite_horizons/presentation/organisms/top_bar_molecule.dart';
135 changes: 135 additions & 0 deletions lib/presentation/organisms/top_bar_molecule.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:infinite_horizons/presentation/atoms/atoms.dart';
import 'package:infinite_horizons/presentation/core/theme_data.dart';

/// Top part of the pages, will show page name and settings logo,
/// and sometimes will have back button.
class TopBarMolecule extends StatelessWidget {
const TopBarMolecule({
required this.pageName,
this.rightIcon,
this.rightIconFunction,
this.leftIcon,
this.leftIconFunction,
this.rightSecondIcon,
this.rightSecondFunction,
this.backgroundColor,
});

/// Page name to show in the left side of the navigation bar
final String? pageName;

/// Icon to show in the right side of the bar
final IconData? rightIcon;

/// Icon to show in the right side of the bar left to the first icon
/// from the right
final IconData? rightSecondIcon;

/// Icon to show in the left side of the bar
final IconData? leftIcon;

/// Function to execute when pressing the icon in the right side
final Function(BuildContext)? rightIconFunction;

/// What to execute if second right icon was pressed
final Function(BuildContext)? rightSecondFunction;

/// What to execute if back button was pressed
final Function(BuildContext)? leftIconFunction;

final Color? backgroundColor;

@override
Widget build(BuildContext context) {
final ThemeData themeData = Theme.of(context);
final ColorScheme colorScheme = themeData.colorScheme;
final TextTheme textTheme = themeData.textTheme;

final TextStyle style = textTheme.bodyLarge!;

return SafeArea(
child: ColoredBox(
color: backgroundColor != null
? backgroundColor!.withOpacity(0.72)
: colorScheme.background,
child: Container(
margin: const EdgeInsets.fromLTRB(
9,
AppThemeData.generalSpacing,
9,
AppThemeData.generalSpacing,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Row(
children: <Widget>[
if (leftIcon != null)
Container(
alignment: Alignment.centerLeft,
child: IconButton(
icon: FaIcon(
leftIcon,
size: style.fontSize,
color: colorScheme.tertiary,
),
onPressed: () => leftIconFunction!(context),
),
)
else
const SizedBox(),
TextAtom(
pageName!,
style: style.copyWith(color: colorScheme.tertiary),
),
],
),
if (rightIcon != null)
Row(
children: [
if (rightSecondIcon != null)
SizedBox(
width: 70,
child: TextButton(
style: ButtonStyle(
padding: MaterialStateProperty.all<EdgeInsets>(
EdgeInsets.zero,
),
),
onPressed: () => rightSecondFunction!(context),
child: FaIcon(
rightSecondIcon,
size: style.fontSize,
color: style.color,
),
),
),
SizedBox(
width: 25,
child: TextButton(
style: ButtonStyle(
padding: MaterialStateProperty.all<EdgeInsets>(
EdgeInsets.zero,
),
),
onPressed: () => rightIconFunction!(context),
child: Icon(
rightIcon,
size: style.fontSize! + 5,
color: style.color,
),
),
),
],
)
else
const SizedBox(),
],
),
),
),
);
}
}
60 changes: 60 additions & 0 deletions lib/presentation/pages/all_tips.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import 'package:flutter/material.dart';
import 'package:infinite_horizons/domain/tip.dart';
import 'package:infinite_horizons/presentation/atoms/atoms.dart';
import 'package:infinite_horizons/presentation/organisms/organisms.dart';
import 'package:infinite_horizons/presentation/pages/tip_information.dart';

class AllTips extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
children: [
TopBarMolecule(
pageName: 'all_tips',
leftIcon: Icons.arrow_back,
leftIconFunction: (c) => Navigator.of(c).pop(),
),
ListView.separated(
shrinkWrap: true,
itemBuilder: (context, n) {
final Tip tip = tipsList[n];

return UnconstrainedBox(
child: ButtonAtom(
variant: ButtonVariant.tertiary,
onPressed: () => Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => TipInformation(tip),
),
),
text: tip.text,
),
);
},
separatorBuilder: (context, i) => const SeparatorAtom(),
itemCount: tipsList.length,
),
],
),
);
}
}

// ListView.separated(
// shrinkWrap: true,
// physics: const NeverScrollableScrollPhysics(),
// scrollDirection: Axis.horizontal,
// itemBuilder: (context, r) {
// final Uri resource = tip.resourceLinks[r];
//
// return ButtonAtom(
// variant: ButtonVariant.tertiary,
// onPressed: () => launchUrl(resource),
// // TODO: Add to translation
// text: 'Link $r',
// );
// },
// separatorBuilder: (context, r) => const SeparatorAtom(),
// itemCount: tip.resourceLinks.length,
// ),
13 changes: 4 additions & 9 deletions lib/presentation/pages/home_page.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:infinite_horizons/domain/study_type_abstract.dart';
import 'package:infinite_horizons/presentation/atoms/atoms.dart';
import 'package:infinite_horizons/presentation/organisms/organisms.dart';
import 'package:wakelock/wakelock.dart';
import 'package:wakelock_plus/wakelock_plus.dart';

class HomePage extends StatefulWidget {
@override
Expand All @@ -19,16 +17,13 @@ class _HomePageState extends State<HomePage> {
@override
void initState() {
super.initState();
if (!Platform.isLinux) {
Wakelock.enable();
}
WakelockPlus.enable();
}

@override
void dispose() {
if (!Platform.isLinux) {
Wakelock.disable();
}
WakelockPlus.disable();

super.dispose();
}

Expand Down
Loading

0 comments on commit 1fdcab5

Please sign in to comment.