124 lines
4.0 KiB
Dart
124 lines
4.0 KiB
Dart
import 'package:flutter/material.dart';
|
||
import 'package:flutter_svg/svg.dart';
|
||
import 'package:stacked/stacked.dart';
|
||
import 'package:yimaru_app/ui/common/app_colors.dart';
|
||
import 'package:yimaru_app/ui/common/ui_helpers.dart';
|
||
import 'package:yimaru_app/ui/widgets/custom_elevated_button.dart';
|
||
import 'package:yimaru_app/ui/widgets/large_app_bar.dart';
|
||
|
||
import '../../../common/enmus.dart';
|
||
import '../assessment_viewmodel.dart';
|
||
|
||
class StartLessonScreen extends ViewModelWidget<AssessmentViewModel> {
|
||
const StartLessonScreen({super.key});
|
||
|
||
Future<void> _start(AssessmentViewModel viewModel) async {
|
||
if (viewModel.proficiencyLevel != ProficiencyLevels.none) {
|
||
Map<String, dynamic> data = {
|
||
'preferred_language': 'en',
|
||
'knowledge_level': viewModel.proficiencyLevel.name.toUpperCase()
|
||
};
|
||
|
||
viewModel.addUserData(data);
|
||
}
|
||
|
||
await viewModel.completeProfile();
|
||
}
|
||
|
||
@override
|
||
Widget build(BuildContext context, AssessmentViewModel viewModel) =>
|
||
_buildScaffoldWrapper(viewModel);
|
||
|
||
Widget _buildScaffoldWrapper(AssessmentViewModel viewModel) => Scaffold(
|
||
backgroundColor: kcBackgroundColor,
|
||
body: _buildScaffold(viewModel),
|
||
);
|
||
|
||
Widget _buildScaffold(AssessmentViewModel viewModel) => Column(
|
||
crossAxisAlignment: CrossAxisAlignment.start,
|
||
children: _buildScaffoldChildren(viewModel),
|
||
);
|
||
|
||
List<Widget> _buildScaffoldChildren(AssessmentViewModel viewModel) =>
|
||
[_buildAppBar(), _buildExpandedBody(viewModel)];
|
||
|
||
Widget _buildAppBar() => const LargeAppBar(
|
||
showBackButton: false,
|
||
showLanguageSelection: false,
|
||
);
|
||
|
||
Widget _buildExpandedBody(AssessmentViewModel viewModel) =>
|
||
Expanded(child: _buildBodyWrapper(viewModel));
|
||
|
||
Widget _buildBodyWrapper(AssessmentViewModel viewModel) => Padding(
|
||
padding: const EdgeInsets.symmetric(horizontal: 15),
|
||
child: _buildBody(viewModel),
|
||
);
|
||
|
||
Widget _buildBody(AssessmentViewModel viewModel) => Column(
|
||
crossAxisAlignment: CrossAxisAlignment.center,
|
||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||
children: _buildBodyChildren(viewModel),
|
||
);
|
||
|
||
List<Widget> _buildBodyChildren(AssessmentViewModel viewModel) =>
|
||
[_buildUpperColumn(viewModel), _buildContinueButtonWrapper(viewModel)];
|
||
|
||
Widget _buildUpperColumn(AssessmentViewModel viewModel) => Column(
|
||
mainAxisSize: MainAxisSize.min,
|
||
crossAxisAlignment: CrossAxisAlignment.center,
|
||
children: _buildUpperColumnChildren(viewModel),
|
||
);
|
||
|
||
List<Widget> _buildUpperColumnChildren(AssessmentViewModel viewModel) => [
|
||
verticalSpaceLarge,
|
||
_buildIcon(),
|
||
verticalSpaceMedium,
|
||
_buildTitle(viewModel),
|
||
verticalSpaceSmall,
|
||
_buildSubTitle(),
|
||
];
|
||
|
||
Widget _buildIcon() => SvgPicture.asset('assets/icons/mascot.svg');
|
||
|
||
Widget _buildTitle(AssessmentViewModel viewModel) => Text.rich(
|
||
TextSpan(
|
||
text: 'Welcome aboard',
|
||
style: const TextStyle(
|
||
fontSize: 25,
|
||
color: kcDarkGrey,
|
||
fontWeight: FontWeight.w600,
|
||
),
|
||
children: [
|
||
TextSpan(
|
||
text: ', ${viewModel.userData['first_name']}!',
|
||
style: const TextStyle(
|
||
fontSize: 25,
|
||
color: kcPrimaryColor,
|
||
fontWeight: FontWeight.w600,
|
||
),
|
||
)
|
||
]),
|
||
);
|
||
|
||
Widget _buildSubTitle() => const Text(
|
||
'You’re ready to explore your personalized lessons.',
|
||
style: TextStyle(color: kcMediumGrey),
|
||
);
|
||
|
||
Widget _buildContinueButtonWrapper(AssessmentViewModel viewModel) => Padding(
|
||
padding: const EdgeInsets.only(bottom: 50),
|
||
child: _buildContinueButton(viewModel),
|
||
);
|
||
|
||
Widget _buildContinueButton(AssessmentViewModel viewModel) =>
|
||
CustomElevatedButton(
|
||
height: 55,
|
||
borderRadius: 12,
|
||
text: 'Go to My Lessons',
|
||
foregroundColor: kcWhite,
|
||
backgroundColor: kcPrimaryColor,
|
||
onTap: () async => await _start(viewModel),
|
||
);
|
||
}
|