forked from eatvio/eatvio_app
Created a new Profile section, added new styles, made some layouts for user profile screen
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '/core/app_export.dart';
|
||||
import 'package:eatvio_app/presentation/registration/height_screen/models/height_model.dart';
|
||||
part 'height_event.dart';
|
||||
part 'height_state.dart';
|
||||
|
||||
/// A bloc that manages the state of a Height according to the event that is dispatched to it.
|
||||
class HeightBloc extends Bloc<HeightEvent, HeightState> {
|
||||
HeightBloc(HeightState initialState) : super(initialState) {
|
||||
on<HeightInitialEvent>(_onInitialize);
|
||||
on<ChangeDropDownEvent>(_changeDropDown);
|
||||
}
|
||||
|
||||
_onInitialize(
|
||||
HeightInitialEvent event,
|
||||
Emitter<HeightState> emit,
|
||||
) async {
|
||||
emit(state.copyWith(
|
||||
heightModelObj: state.heightModelObj
|
||||
?.copyWith(dropdownItemList: fillDropdownItemList())));
|
||||
}
|
||||
|
||||
_changeDropDown(
|
||||
ChangeDropDownEvent event,
|
||||
Emitter<HeightState> emit,
|
||||
) {
|
||||
emit(state.copyWith(selectedDropDownValue: event.value));
|
||||
state.heightModelObj?.userRegistrationSheet.height = event.value.title;
|
||||
}
|
||||
|
||||
List<SelectionPopupModel> fillDropdownItemList() {
|
||||
List<SelectionPopupModel> selectionPopupModels = [];
|
||||
|
||||
for (int i = 140; i <= 220; i++) {
|
||||
selectionPopupModels
|
||||
.add(SelectionPopupModel(id: i - 34, title: i.toString()));
|
||||
}
|
||||
return selectionPopupModels;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// ignore_for_file: must_be_immutable
|
||||
|
||||
part of 'height_bloc.dart';
|
||||
|
||||
/// Abstract class for all events that can be dispatched from the
|
||||
///Height widget.
|
||||
///
|
||||
/// Events must be immutable and implement the [Equatable] interface.
|
||||
@immutable
|
||||
abstract class HeightEvent extends Equatable {}
|
||||
|
||||
/// Event that is dispatched when the Height widget is first created.
|
||||
class HeightInitialEvent extends HeightEvent {
|
||||
@override
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
|
||||
///event for dropdown selection
|
||||
class ChangeDropDownEvent extends HeightEvent {
|
||||
ChangeDropDownEvent({required this.value});
|
||||
|
||||
SelectionPopupModel value;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
value,
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
// ignore_for_file: must_be_immutable
|
||||
|
||||
part of 'height_bloc.dart';
|
||||
|
||||
/// Represents the state of Height in the application.
|
||||
class HeightState extends Equatable {
|
||||
HeightState({
|
||||
this.selectedDropDownValue,
|
||||
this.heightModelObj,
|
||||
});
|
||||
|
||||
SelectionPopupModel? selectedDropDownValue;
|
||||
|
||||
HeightModel? heightModelObj;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
selectedDropDownValue,
|
||||
heightModelObj,
|
||||
];
|
||||
HeightState copyWith({
|
||||
SelectionPopupModel? selectedDropDownValue,
|
||||
HeightModel? heightModelObj,
|
||||
}) {
|
||||
return HeightState(
|
||||
selectedDropDownValue:
|
||||
selectedDropDownValue ?? this.selectedDropDownValue,
|
||||
heightModelObj: heightModelObj ?? this.heightModelObj,
|
||||
);
|
||||
}
|
||||
}
|
||||
127
lib/presentation/registration/height_screen/height_screen.dart
Normal file
127
lib/presentation/registration/height_screen/height_screen.dart
Normal file
@@ -0,0 +1,127 @@
|
||||
import 'bloc/height_bloc.dart';
|
||||
import 'models/height_model.dart';
|
||||
import 'package:eatvio_app/core/app_export.dart';
|
||||
import 'package:eatvio_app/widgets/app_bar/appbar_leading_image.dart';
|
||||
import 'package:eatvio_app/widgets/app_bar/appbar_title_image.dart';
|
||||
import 'package:eatvio_app/widgets/app_bar/custom_app_bar.dart';
|
||||
import 'package:eatvio_app/widgets/custom_drop_down.dart';
|
||||
import 'package:eatvio_app/widgets/next_step_button.dart';
|
||||
import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class HeightScreen extends StatefulWidget {
|
||||
const HeightScreen({Key? key}) : super(key: key);
|
||||
|
||||
static Widget builder(BuildContext context) {
|
||||
final sheet =
|
||||
ModalRoute.of(context)!.settings.arguments as UserRegistrationSheet;
|
||||
return BlocProvider<HeightBloc>(
|
||||
create: (context) => HeightBloc(HeightState(
|
||||
heightModelObj: HeightModel(userRegistrationSheet: sheet)))
|
||||
..add(HeightInitialEvent()),
|
||||
child: HeightScreen());
|
||||
}
|
||||
|
||||
@override
|
||||
State<HeightScreen> createState() => _HeightScreenState();
|
||||
}
|
||||
|
||||
class _HeightScreenState extends State<HeightScreen> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
mediaQueryData = MediaQuery.of(context);
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: _buildAppBar(context),
|
||||
body: Container(
|
||||
width: double.maxFinite,
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.h, vertical: 9.v),
|
||||
child: Column(children: [
|
||||
SizedBox(height: 7.v),
|
||||
Container(
|
||||
height: 16.v,
|
||||
width: 343.h,
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.onPrimary,
|
||||
borderRadius: BorderRadius.circular(8.h),
|
||||
border: Border.all(
|
||||
color: theme.colorScheme.primary, width: 1.h)),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(8.h),
|
||||
child: LinearProgressIndicator(
|
||||
value: 0.55,
|
||||
backgroundColor: theme.colorScheme.onPrimary,
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
appTheme.blueA400)))),
|
||||
SizedBox(height: 39.v),
|
||||
Column(children: [
|
||||
Text("height_measurements".tr,
|
||||
style: theme.textTheme.headlineSmall),
|
||||
SizedBox(height: 174.v),
|
||||
Column(children: [
|
||||
Text("your_height".tr, style: theme.textTheme.bodyLarge),
|
||||
SizedBox(height: 4.v),
|
||||
BlocSelector<HeightBloc, HeightState, HeightModel?>(
|
||||
selector: (state) => state.heightModelObj,
|
||||
builder: (context, heightModelObj) {
|
||||
return CustomDropDown(
|
||||
icon: Container(
|
||||
margin: EdgeInsets.fromLTRB(
|
||||
30.h, 11.v, 17.h, 11.v),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius:
|
||||
BorderRadius.circular(1.h)),
|
||||
child: CustomImageView(
|
||||
imagePath: ImageConstant.imgFavorite,
|
||||
height: 12.adaptSize,
|
||||
width: 12.adaptSize)),
|
||||
hintText: "170",
|
||||
items: heightModelObj?.dropdownItemList ?? [],
|
||||
onChanged: (value) {
|
||||
context
|
||||
.read<HeightBloc>()
|
||||
.add(ChangeDropDownEvent(value: value));
|
||||
});
|
||||
})
|
||||
])
|
||||
]),
|
||||
Spacer(),
|
||||
BlocBuilder<HeightBloc, HeightState>(
|
||||
builder: (context, state) {
|
||||
return NextStepButton(
|
||||
text: "continue".tr.toUpperCase(),
|
||||
margin: EdgeInsets.only(
|
||||
left: 16.h, right: 16.h, bottom: 50.v),
|
||||
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
|
||||
onPressed: () {
|
||||
UserRegistrationSheet sheet =
|
||||
state.heightModelObj!.userRegistrationSheet;
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
AppRoutes.bloodPressureScreen,
|
||||
arguments: sheet,
|
||||
);
|
||||
});
|
||||
}),
|
||||
]))));
|
||||
}
|
||||
|
||||
/// Section Widget
|
||||
PreferredSizeWidget _buildAppBar(BuildContext context) {
|
||||
return CustomAppBar(
|
||||
leadingWidth: 29.h,
|
||||
leading: AppbarLeadingImage(
|
||||
imagePath: ImageConstant.imgArrowLeft,
|
||||
margin: EdgeInsets.only(left: 16.h, top: 15.v, bottom: 15.v),
|
||||
onTap: () {
|
||||
onTapArrowLeft(context);
|
||||
}),
|
||||
centerTitle: true,
|
||||
title: AppbarTitleImage(imagePath: ImageConstant.imgLogoEatvio));
|
||||
}
|
||||
|
||||
/// Navigates to the previous screen.
|
||||
onTapArrowLeft(BuildContext context) {
|
||||
NavigatorService.goBack();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// ignore_for_file: must_be_immutable
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:eatvio_app/data/models/selectionPopupModel/selection_popup_model.dart';
|
||||
import 'package:eatvio_app/data/models/userRegistrationModel/user_registration_model.dart';
|
||||
|
||||
/// This class defines the variables used in the [height_screen],
|
||||
/// and is typically used to hold data that is passed between different parts of the application.
|
||||
class HeightModel extends Equatable {
|
||||
UserRegistrationSheet userRegistrationSheet;
|
||||
HeightModel(
|
||||
{this.dropdownItemList = const [], required this.userRegistrationSheet});
|
||||
|
||||
List<SelectionPopupModel> dropdownItemList;
|
||||
|
||||
HeightModel copyWith({List<SelectionPopupModel>? dropdownItemList}) {
|
||||
return HeightModel(
|
||||
userRegistrationSheet: userRegistrationSheet,
|
||||
dropdownItemList: dropdownItemList ?? this.dropdownItemList,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [dropdownItemList, userRegistrationSheet];
|
||||
}
|
||||
Reference in New Issue
Block a user