-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #73 from nimblehq/feature/72-ui-survey-question
[#72] [UI] As the user, I can see the survey question
- Loading branch information
Showing
9 changed files
with
295 additions
and
79 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:go_router/go_router.dart'; | ||
import 'package:survey_flutter/gen/assets.gen.dart'; | ||
import 'package:survey_flutter/model/survey_model.dart'; | ||
import 'package:survey_flutter/screens/app_route.dart'; | ||
import 'package:survey_flutter/theme/app_constants.dart'; | ||
import 'package:survey_flutter/theme/primary_button_style.dart'; | ||
import 'package:survey_flutter/utils/build_context_ext.dart'; | ||
|
||
const _buttonHeight = 56.0; | ||
|
||
class SurveyDetailScreen extends StatelessWidget { | ||
final SurveyModel survey; | ||
SurveyDetailScreen({ | ||
super.key, | ||
required this.survey, | ||
}); | ||
|
||
late final _backgroundImage = FadeInImage.assetNetwork( | ||
placeholder: Assets.images.placeholder.path, | ||
image: survey.coverImageUrl, | ||
fit: BoxFit.cover, | ||
width: double.infinity, | ||
height: double.infinity, | ||
); | ||
|
||
late final _gradientOverlay = Container( | ||
decoration: BoxDecoration( | ||
gradient: LinearGradient( | ||
begin: Alignment.topCenter, | ||
end: Alignment.bottomCenter, | ||
colors: [ | ||
Colors.black.withOpacity(0.8), | ||
Colors.black.withOpacity(0.2), | ||
Colors.black.withOpacity(0.8), | ||
], | ||
), | ||
), | ||
); | ||
|
||
Widget _buildTitle(BuildContext context) { | ||
return Text( | ||
survey.title, | ||
style: context.textTheme.titleMedium, | ||
maxLines: 2, | ||
); | ||
} | ||
|
||
Widget _buildDescription(BuildContext context) { | ||
return Text( | ||
survey.description, | ||
style: context.textTheme.bodyMedium, | ||
maxLines: 2, | ||
); | ||
} | ||
|
||
Widget _buildButton(BuildContext context) { | ||
return SizedBox( | ||
height: _buttonHeight, | ||
child: ElevatedButton( | ||
style: PrimaryButtonStyle( | ||
hintTextStyle: context.textTheme.labelMedium, | ||
), | ||
child: Text( | ||
context.localizations.startSurveyText, | ||
), | ||
onPressed: () { | ||
// TODO: Pass survey question model | ||
context.push( | ||
AppRoute.questions.path, | ||
); | ||
}, | ||
), | ||
); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
backgroundColor: Colors.transparent, | ||
elevation: 0, | ||
), | ||
extendBodyBehindAppBar: true, | ||
body: Stack( | ||
children: [ | ||
_backgroundImage, | ||
_gradientOverlay, | ||
Container( | ||
padding: const EdgeInsets.only( | ||
bottom: Metrics.spacing20, | ||
left: Metrics.spacing20, | ||
right: Metrics.spacing20, | ||
), | ||
child: SafeArea( | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
_buildTitle(context), | ||
const SizedBox(height: Metrics.spacing16), | ||
_buildDescription(context), | ||
const Spacer(), | ||
Row( | ||
children: [ | ||
const Spacer(), | ||
_buildButton(context), | ||
], | ||
), | ||
], | ||
), | ||
), | ||
), | ||
], | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:survey_flutter/theme/app_constants.dart'; | ||
import 'package:survey_flutter/utils/build_context_ext.dart'; | ||
|
||
const _counterOpacity = 0.5; | ||
|
||
class SurveyQuestionWidget extends StatelessWidget { | ||
final int displayOrder; | ||
final int numberOfQuestions; | ||
|
||
const SurveyQuestionWidget({ | ||
Key? key, | ||
required this.displayOrder, | ||
required this.numberOfQuestions, | ||
}) : super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return SafeArea( | ||
child: Padding( | ||
padding: const EdgeInsets.symmetric( | ||
vertical: Metrics.spacing54, | ||
horizontal: Metrics.spacing20, | ||
), | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
_buildQuestionCounter(context), | ||
const SizedBox(height: Metrics.spacing8), | ||
_buildQuestion(context), | ||
], | ||
), | ||
), | ||
); | ||
} | ||
|
||
Widget _buildQuestionCounter(BuildContext context) => Text( | ||
"$displayOrder/$numberOfQuestions", | ||
style: context.textTheme.headlineSmall | ||
?.copyWith(color: Colors.white.withOpacity(_counterOpacity)), | ||
); | ||
|
||
Widget _buildQuestion(BuildContext context) => | ||
// TODO: remove text in integrate | ||
Text( | ||
"How fulfilled did you feel during this WFH period?", | ||
style: context.textTheme.titleLarge?.copyWith(color: Colors.white), | ||
maxLines: 3, | ||
); | ||
} |
Oops, something went wrong.