Skip to content

Commit be5b16a

Browse files
authored
Merge pull request #56 from nimblehq/feature/14-ui-survey-list
[#14] [UI] As a logged-in user, I can see the survey list on the Home screen
2 parents d0b4046 + 57ceddc commit be5b16a

16 files changed

+277
-3
lines changed

assets/images/2.0x/next.png

548 Bytes
Loading

assets/images/3.0x/next.png

683 Bytes
Loading

assets/images/dummy_avatar.png

2.98 KB
Loading

assets/images/dummy_background.png

234 KB
Loading

assets/images/next.png

314 Bytes
Loading

lib/l10n/app_en.arb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@
88
"unauthorizedError": "Your email or password is incorrect.\nPlease try again.",
99
"noInternetConnectionError": "You seem to be offline.\nPlease try again!",
1010
"genericError": "Something went wrong.\nPlease try again!",
11-
"loginFailAlertTitle": "Unable to log in"
11+
"loginFailAlertTitle": "Unable to log in",
12+
"today": "Today"
1213
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:survey_flutter/gen/assets.gen.dart';
3+
import 'package:survey_flutter/theme/app_constants.dart';
4+
import 'package:survey_flutter/utils/build_context_ext.dart';
5+
6+
const _descriptionOpacity = 0.7;
7+
const _buttonSize = 56.0;
8+
9+
class HomeFooterWidget extends StatelessWidget {
10+
const HomeFooterWidget({
11+
Key? key,
12+
required VoidCallback onNextButtonPressed,
13+
}) : super(key: key);
14+
15+
@override
16+
Widget build(BuildContext context) {
17+
return Container(
18+
padding: const EdgeInsets.symmetric(horizontal: Metrics.spacing20),
19+
child: Column(
20+
crossAxisAlignment: CrossAxisAlignment.start,
21+
children: [
22+
_buildTitle(context),
23+
const SizedBox(height: Metrics.spacing16),
24+
_buildDescription(context),
25+
],
26+
),
27+
);
28+
}
29+
30+
Widget _buildTitle(BuildContext context) {
31+
// TODO: Replace with survey title
32+
return Text(
33+
"Working from home Check-In",
34+
style: context.textTheme.titleMedium,
35+
maxLines: 2,
36+
);
37+
}
38+
39+
Widget _buildDescription(BuildContext context) {
40+
// TODO: Replace with survey description
41+
return Row(
42+
children: [
43+
Expanded(
44+
child: Text(
45+
"We would like to know how you feel about our work from home...",
46+
style: context.textTheme.bodyMedium?.copyWith(
47+
color: Colors.white.withOpacity(_descriptionOpacity)),
48+
maxLines: 2,
49+
),
50+
),
51+
_buildNextButton(),
52+
],
53+
);
54+
}
55+
56+
Widget _buildNextButton() {
57+
return SizedBox(
58+
width: _buttonSize,
59+
height: _buttonSize,
60+
child: ElevatedButton(
61+
style: ElevatedButton.styleFrom(
62+
shape: const CircleBorder(),
63+
backgroundColor: Colors.white,
64+
foregroundColor: Colors.black12,
65+
),
66+
child: Image.asset(
67+
Assets.images.next.path,
68+
color: Colors.black,
69+
),
70+
onPressed: () {
71+
// TODO: Handle the next button pressed event
72+
},
73+
),
74+
);
75+
}
76+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import 'package:survey_flutter/gen/assets.gen.dart';
2+
import 'package:flutter/material.dart';
3+
import 'package:survey_flutter/theme/app_constants.dart';
4+
import 'package:survey_flutter/utils/build_context_ext.dart';
5+
import 'package:survey_flutter/utils/date_time_util.dart';
6+
7+
const _avatarSize = 36.0;
8+
9+
class HomeHeaderWidget extends StatelessWidget {
10+
const HomeHeaderWidget({Key? key}) : super(key: key);
11+
12+
@override
13+
Widget build(BuildContext context) {
14+
final currentDate = DateTime.now().fullDate.toUpperCase();
15+
16+
return SafeArea(
17+
child: Padding(
18+
padding: const EdgeInsets.symmetric(
19+
horizontal: Metrics.spacing20,
20+
vertical: Metrics.spacing28,
21+
),
22+
child: Row(
23+
crossAxisAlignment: CrossAxisAlignment.start,
24+
children: [
25+
_buildHeaderInfo(context, currentDate),
26+
const Spacer(),
27+
_buildProfileAvatar(),
28+
],
29+
),
30+
),
31+
);
32+
}
33+
34+
Widget _buildHeaderInfo(BuildContext context, String currentDateFormatted) {
35+
return Column(
36+
crossAxisAlignment: CrossAxisAlignment.start,
37+
children: [
38+
Text(
39+
currentDateFormatted,
40+
style: context.textTheme.labelSmall,
41+
),
42+
const SizedBox(height: Metrics.spacing4),
43+
Text(
44+
context.localizations.today,
45+
style: context.textTheme.titleLarge,
46+
),
47+
],
48+
);
49+
}
50+
51+
Widget _buildProfileAvatar() {
52+
return Container(
53+
margin: const EdgeInsets.only(top: Metrics.spacing20),
54+
width: _avatarSize,
55+
height: _avatarSize,
56+
child: CircleAvatar(
57+
radius: _avatarSize,
58+
backgroundImage: AssetImage(Assets.images.dummyAvatar.path),
59+
),
60+
);
61+
}
62+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:page_view_dot_indicator/page_view_dot_indicator.dart';
3+
4+
const _opacityUnselectedColor = 0.2;
5+
const _indicatorSize = 8.0;
6+
const dotIndicatorSize = Size(
7+
_indicatorSize,
8+
_indicatorSize,
9+
);
10+
11+
class HomePageIndicatorWidget extends StatelessWidget {
12+
const HomePageIndicatorWidget({Key? key}) : super(key: key);
13+
14+
@override
15+
Widget build(BuildContext context) {
16+
// TODO: currentItem and count handled in Integrate
17+
return PageViewDotIndicator(
18+
currentItem: 1,
19+
count: 3,
20+
selectedColor: Colors.white,
21+
unselectedColor: Colors.white.withOpacity(_opacityUnselectedColor),
22+
size: dotIndicatorSize,
23+
unselectedSize: dotIndicatorSize,
24+
alignment: Alignment.bottomLeft,
25+
);
26+
}
27+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:survey_flutter/gen/assets.gen.dart';
3+
import 'package:survey_flutter/screens/home/home_footer_widget.dart';
4+
import 'package:survey_flutter/theme/app_constants.dart';
5+
6+
class HomePagesWidget extends StatelessWidget {
7+
final PageController _pageController = PageController();
8+
9+
HomePagesWidget({Key? key}) : super(key: key);
10+
11+
@override
12+
Widget build(BuildContext context) {
13+
// TODO: itemCount and background image handled in integrate
14+
return PageView.builder(
15+
itemCount: 4,
16+
controller: _pageController,
17+
itemBuilder: (_, int index) {
18+
return Container(
19+
decoration: BoxDecoration(
20+
image: DecorationImage(
21+
image: AssetImage(Assets.images.dummyBackground.path),
22+
fit: BoxFit.cover,
23+
),
24+
),
25+
child: Column(
26+
children: [
27+
const Spacer(), // Space above footer
28+
SafeArea(
29+
bottom: true,
30+
child: Padding(
31+
padding: const EdgeInsets.only(
32+
left: 0,
33+
bottom: Metrics.spacing20,
34+
right: 0,
35+
),
36+
child: HomeFooterWidget(
37+
onNextButtonPressed: () {
38+
// Handle the next button pressed event
39+
},
40+
),
41+
),
42+
),
43+
],
44+
),
45+
);
46+
},
47+
);
48+
}
49+
}

0 commit comments

Comments
 (0)