Skip to content

Commit 5343939

Browse files
mateobelangerMathieu Bélanger
and
Mathieu Bélanger
authored
Mobile/install guide (#90)
* New sliverbar asset & app icon * Purple accent color in match of webapp, new sliverbar background * Changed drawer top image * Added card with link to setup guide * SliverAppBar title dissapears when collapsed * renamed setup guide button Co-authored-by: Mathieu Bélanger <mathieu.belanger@logient.com>
1 parent 0d0f59f commit 5343939

File tree

19 files changed

+523
-37
lines changed

19 files changed

+523
-37
lines changed

mobile/android/app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@
5050
android:value="2" />
5151
</application>
5252
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
53-
</manifest>
53+
</manifest>
Loading
Loading
Loading
Loading
Loading

mobile/common/assets/img/Dodo4.png

49.2 KB
Loading

mobile/common/assets/img/Dodo4.svg

Lines changed: 233 additions & 0 deletions
Loading

mobile/common/assets/img/Objets.png

235 KB
Loading
267 KB
Loading
Loading

mobile/lib/src/constants.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
const SETUP_GUIDE_URL =
2+
'https://polycortex.github.io/polydodo/#/record-my-sleep';

mobile/lib/src/presentation/navigation/navdrawer_widget.dart

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@ class NavDrawer extends StatelessWidget {
1717
Widget build(BuildContext context) {
1818
return Drawer(
1919
child: ListView(
20-
padding: EdgeInsets.zero, //only(top: 8.0),
20+
padding: EdgeInsets.only(top: 45.0),
2121
children: <Widget>[
2222
_createHeader(),
2323
_createDrawerItem(
2424
icon: Icons.dashboard,
2525
text: 'Dashboard',
2626
route: Routes.dashboardPage,
27+
tab: NavdrawerTab.Dashboard,
2728
context: context,
2829
),
2930
// Todo: find the real place for the device selector, up to debate
@@ -37,12 +38,14 @@ class NavDrawer extends StatelessWidget {
3738
icon: Icons.hotel,
3839
text: 'Record Sleep sequence',
3940
route: Routes.recordSleepGuidePage,
41+
tab: NavdrawerTab.RecordSleep,
4042
context: context,
4143
),
4244
_createDrawerItem(
4345
icon: Icons.analytics,
4446
text: 'History',
4547
route: Routes.sleepHistoryPage,
48+
tab: NavdrawerTab.History,
4649
context: context,
4750
),
4851
],
@@ -52,22 +55,18 @@ class NavDrawer extends StatelessWidget {
5255

5356
Widget _createHeader() {
5457
return DrawerHeader(
55-
margin: EdgeInsets.zero,
56-
padding: EdgeInsets.zero,
57-
decoration: BoxDecoration(
58-
image: DecorationImage(
59-
fit: BoxFit.fill,
60-
image: AssetImage('common/assets/img/Material-Wallpaper.jpg'))),
61-
child: Stack(children: <Widget>[
62-
Positioned(
63-
bottom: 12.0,
64-
left: 16.0,
65-
child: Text('Polydodo',
66-
style: TextStyle(
67-
color: Colors.white,
68-
fontSize: 20.0,
69-
fontWeight: FontWeight.w500))),
70-
]));
58+
margin: EdgeInsets.zero,
59+
padding: EdgeInsets.zero,
60+
decoration: BoxDecoration(
61+
color: Color(3289693),
62+
image: DecorationImage(
63+
scale: 15,
64+
fit: BoxFit.fitWidth,
65+
image: AssetImage('common/assets/img/Objets.png'),
66+
),
67+
),
68+
child: Stack(children: <Widget>[]),
69+
);
7170
}
7271

7372
Widget _createDrawerItem(
@@ -87,9 +86,7 @@ class NavDrawer extends StatelessWidget {
8786
],
8887
),
8988
onTap: () {
90-
//context.bloc<NavdrawerBloc>().add(NavdrawerUpdated(state));
9189
ExtendedNavigator.of(context).popAndPush(route);
92-
// ExtendedNavigator.of(context).replace(route);
9390
},
9491
selected: activeTab == tab,
9592
);

mobile/lib/src/presentation/pages/dashboard/dashboard_page.dart

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'package:flutter/material.dart';
22
import 'package:polydodo/src/presentation/navigation/navdrawer_tabs.dart';
33
import 'package:polydodo/src/presentation/navigation/navdrawer_widget.dart';
4+
import 'package:polydodo/src/presentation/pages/dashboard/sliver_app_bar_title.dart';
45

56
class DashboardPage extends StatelessWidget {
67
@override
@@ -12,20 +13,19 @@ class DashboardPage extends StatelessWidget {
1213
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
1314
return <Widget>[
1415
SliverAppBar(
16+
brightness: Brightness.dark,
1517
expandedHeight: 200.0,
16-
floating: false,
1718
pinned: true,
19+
title: SliverAppBarTitle(child: Text('Polydodo')),
1820
flexibleSpace: FlexibleSpaceBar(
19-
centerTitle: false,
20-
title: Text('Polydodo',
21-
style: TextStyle(
22-
color: Colors.white,
23-
fontSize: 16.0,
24-
)),
25-
background: Image.network(
26-
'https://images.pexels.com/photos/396547/pexels-photo-396547.jpeg?auto=compress&cs=tinysrgb&h=350',
21+
centerTitle: true,
22+
background: Container(
23+
child: Image.asset(
24+
'common/assets/img/polydodo_sliverbar_3_e.png',
2725
fit: BoxFit.cover,
28-
)),
26+
),
27+
),
28+
),
2929
),
3030
];
3131
},
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import 'package:flutter/material.dart';
2+
3+
class SliverAppBarTitle extends StatefulWidget {
4+
final Widget child;
5+
const SliverAppBarTitle({
6+
Key key,
7+
@required this.child,
8+
}) : super(key: key);
9+
@override
10+
_SliverAppBarTitleState createState() {
11+
return _SliverAppBarTitleState();
12+
}
13+
}
14+
15+
class _SliverAppBarTitleState extends State<SliverAppBarTitle> {
16+
ScrollPosition _position;
17+
bool _visible;
18+
@override
19+
void dispose() {
20+
_removeListener();
21+
super.dispose();
22+
}
23+
24+
@override
25+
void didChangeDependencies() {
26+
super.didChangeDependencies();
27+
_removeListener();
28+
_addListener();
29+
}
30+
31+
void _addListener() {
32+
_position = Scrollable.of(context)?.position;
33+
_position?.addListener(_positionListener);
34+
_positionListener();
35+
}
36+
37+
void _removeListener() {
38+
_position?.removeListener(_positionListener);
39+
}
40+
41+
void _positionListener() {
42+
var settings =
43+
context.dependOnInheritedWidgetOfExactType<FlexibleSpaceBarSettings>();
44+
var visible =
45+
settings == null || settings.currentExtent <= settings.minExtent;
46+
if (_visible != visible) {
47+
setState(() {
48+
_visible = visible;
49+
});
50+
}
51+
}
52+
53+
@override
54+
Widget build(BuildContext context) {
55+
return Visibility(
56+
visible: _visible,
57+
child: widget.child,
58+
);
59+
}
60+
}

mobile/lib/src/presentation/pages/record_sleep/record_sleep_guide_page.dart

Lines changed: 139 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,40 @@ import 'package:auto_route/auto_route.dart';
22
import 'package:flutter/material.dart';
33
import 'package:flutter_bloc/flutter_bloc.dart';
44
import 'package:polydodo/src/application/blocs.dart';
5+
import 'package:polydodo/src/constants.dart';
56
import 'package:polydodo/src/presentation/navigation/navdrawer_tabs.dart';
67
import 'package:polydodo/src/presentation/navigation/navdrawer_widget.dart';
78
import 'package:polydodo/src/presentation/navigation/routes/router.gr.dart';
9+
import 'package:url_launcher/url_launcher.dart';
810

911
class RecordSleepGuidePage extends StatelessWidget {
1012
@override
1113
Widget build(BuildContext context) {
1214
return Scaffold(
13-
appBar: AppBar(title: Text('Record Sleep')),
15+
appBar: AppBar(title: Text('Record a sleep sequence')),
1416
drawer: NavDrawer(activeTab: NavdrawerTab.RecordSleep),
1517
body: PageView(
1618
children: [
17-
Container(child: Center(child: Text('Record Sleep Guide'))),
18-
Container(child: Center(child: Text('Record Sleep next'))),
19+
Container(
20+
child: Center(
21+
child: Column(
22+
children: [
23+
Row(
24+
mainAxisAlignment: MainAxisAlignment.center,
25+
children: [
26+
Padding(
27+
padding: const EdgeInsets.symmetric(
28+
vertical: 100.0,
29+
horizontal: 20,
30+
),
31+
),
32+
],
33+
),
34+
_buildSleepGuideCard(context),
35+
],
36+
),
37+
),
38+
),
1939
],
2040
),
2141
floatingActionButton: FloatingActionButton.extended(
@@ -30,3 +50,119 @@ class RecordSleepGuidePage extends StatelessWidget {
3050
);
3151
}
3252
}
53+
54+
void _launchURL() async {
55+
if (await canLaunch(SETUP_GUIDE_URL)) {
56+
await launch(SETUP_GUIDE_URL);
57+
} else {
58+
throw 'Could not launch $SETUP_GUIDE_URL';
59+
}
60+
}
61+
62+
Widget _buildSleepGuideCard(BuildContext context) {
63+
return Container(
64+
child: InkWell(
65+
onTap: _launchURL,
66+
child: Container(
67+
height: 345.0,
68+
margin: EdgeInsets.all(10.0),
69+
width: 400.0,
70+
child: Stack(
71+
alignment: Alignment.topCenter,
72+
children: <Widget>[
73+
Positioned(
74+
bottom: 15.0,
75+
child: Container(
76+
height: 150.0,
77+
width: 320.0,
78+
decoration: BoxDecoration(
79+
color: Colors.white,
80+
borderRadius: BorderRadius.circular(10.0),
81+
),
82+
child: Padding(
83+
padding: EdgeInsets.all(5.0),
84+
child: Column(
85+
mainAxisAlignment: MainAxisAlignment.end,
86+
crossAxisAlignment: CrossAxisAlignment.start,
87+
children: <Widget>[
88+
Text(
89+
'Setup Guide',
90+
style: TextStyle(
91+
fontSize: 22.0,
92+
fontWeight: FontWeight.w600,
93+
letterSpacing: 1.2,
94+
),
95+
),
96+
Text(
97+
"Prior to starting the recording, make sure that you've followed the installation procedures stated in this guide.",
98+
style: TextStyle(
99+
color: Colors.grey,
100+
fontSize: 12,
101+
),
102+
),
103+
],
104+
),
105+
),
106+
),
107+
),
108+
Container(
109+
decoration: BoxDecoration(
110+
color: Theme.of(context).primaryColor,
111+
borderRadius: BorderRadius.circular(20.0),
112+
boxShadow: [
113+
BoxShadow(
114+
color: Colors.black26,
115+
offset: Offset(0.0, 2.0),
116+
blurRadius: 6.0,
117+
),
118+
],
119+
),
120+
child: Stack(
121+
children: <Widget>[
122+
Hero(
123+
tag: 'common/assets/img/Objets.png',
124+
child: ClipRRect(
125+
borderRadius: BorderRadius.circular(20.0),
126+
child: Image(
127+
height: 250.0,
128+
width: 305.0,
129+
image: AssetImage('common/assets/img/Objets.png'),
130+
fit: BoxFit.cover,
131+
),
132+
),
133+
),
134+
Positioned(
135+
left: 80.0,
136+
bottom: 10.0,
137+
child: Column(
138+
crossAxisAlignment: CrossAxisAlignment.center,
139+
mainAxisAlignment: MainAxisAlignment.center,
140+
children: <Widget>[
141+
Row(
142+
children: <Widget>[
143+
Icon(
144+
Icons.book,
145+
size: 15.0,
146+
color: Colors.white,
147+
),
148+
SizedBox(width: 5.0),
149+
Text(
150+
'Tap to open the guide',
151+
style: TextStyle(
152+
color: Colors.white,
153+
),
154+
),
155+
],
156+
),
157+
],
158+
),
159+
),
160+
],
161+
),
162+
)
163+
],
164+
),
165+
),
166+
),
167+
);
168+
}

mobile/lib/src/theme.dart

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
import 'package:flutter/material.dart';
22

33
final theme = ThemeData(
4-
primarySwatch: Colors.blue,
4+
primaryColor: HexColor('32325D'),
5+
buttonColor: HexColor('FC7C5F'),
6+
floatingActionButtonTheme:
7+
FloatingActionButtonThemeData(backgroundColor: HexColor('FC7C5F')),
58
visualDensity: VisualDensity.adaptivePlatformDensity,
69
);
10+
11+
class HexColor extends Color {
12+
static int _getColorFromHex(String hexColor) {
13+
hexColor = hexColor.toUpperCase().replaceAll('#', '');
14+
if (hexColor.length == 6) {
15+
hexColor = 'FF' + hexColor;
16+
}
17+
return int.parse(hexColor, radix: 16);
18+
}
19+
20+
HexColor(final String hexColor) : super(_getColorFromHex(hexColor));
21+
}

0 commit comments

Comments
 (0)