forked from eatvio/eatvio_app
New screen names
This commit is contained in:
38
lib/presentation/weight_screen/bloc/weight_bloc.dart
Normal file
38
lib/presentation/weight_screen/bloc/weight_bloc.dart
Normal file
@@ -0,0 +1,38 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '/core/app_export.dart';
|
||||
import 'package:eatvio_app/presentation/weight_screen/models/weight_model.dart';
|
||||
part 'weight_event.dart';
|
||||
part 'weight_state.dart';
|
||||
|
||||
/// A bloc that manages the state of a Weight according to the event that is dispatched to it.
|
||||
class WeightBloc extends Bloc<WeightEvent, WeightState> {
|
||||
WeightBloc(WeightState initialState) : super(initialState) {
|
||||
on<WeightInitialEvent>(_onInitialize);
|
||||
on<ChangeDropDownEvent>(_changeDropDown);
|
||||
}
|
||||
|
||||
_onInitialize(
|
||||
WeightInitialEvent event,
|
||||
Emitter<WeightState> emit,
|
||||
) async {
|
||||
emit(state.copyWith(
|
||||
weightModelObj: state.weightModelObj
|
||||
?.copyWith(dropdownItemList: fillDropdownItemList())));
|
||||
}
|
||||
|
||||
_changeDropDown(
|
||||
ChangeDropDownEvent event,
|
||||
Emitter<WeightState> emit,
|
||||
) {
|
||||
emit(state.copyWith(selectedDropDownValue: event.value));
|
||||
}
|
||||
|
||||
List<SelectionPopupModel> fillDropdownItemList() {
|
||||
return [
|
||||
SelectionPopupModel(id: 1, title: "Item One", isSelected: true),
|
||||
SelectionPopupModel(id: 2, title: "Item Two"),
|
||||
SelectionPopupModel(id: 3, title: "Item Three")
|
||||
];
|
||||
}
|
||||
}
|
||||
28
lib/presentation/weight_screen/bloc/weight_event.dart
Normal file
28
lib/presentation/weight_screen/bloc/weight_event.dart
Normal file
@@ -0,0 +1,28 @@
|
||||
// ignore_for_file: must_be_immutable
|
||||
|
||||
part of 'weight_bloc.dart';
|
||||
|
||||
/// Abstract class for all events that can be dispatched from the
|
||||
///Weight widget.
|
||||
///
|
||||
/// Events must be immutable and implement the [Equatable] interface.
|
||||
@immutable
|
||||
abstract class WeightEvent extends Equatable {}
|
||||
|
||||
/// Event that is dispatched when the Weight widget is first created.
|
||||
class WeightInitialEvent extends WeightEvent {
|
||||
@override
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
|
||||
///event for dropdown selection
|
||||
class ChangeDropDownEvent extends WeightEvent {
|
||||
ChangeDropDownEvent({required this.value});
|
||||
|
||||
SelectionPopupModel value;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
value,
|
||||
];
|
||||
}
|
||||
31
lib/presentation/weight_screen/bloc/weight_state.dart
Normal file
31
lib/presentation/weight_screen/bloc/weight_state.dart
Normal file
@@ -0,0 +1,31 @@
|
||||
// ignore_for_file: must_be_immutable
|
||||
|
||||
part of 'weight_bloc.dart';
|
||||
|
||||
/// Represents the state of Weight in the application.
|
||||
class WeightState extends Equatable {
|
||||
WeightState({
|
||||
this.selectedDropDownValue,
|
||||
this.weightModelObj,
|
||||
});
|
||||
|
||||
SelectionPopupModel? selectedDropDownValue;
|
||||
|
||||
WeightModel? weightModelObj;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
selectedDropDownValue,
|
||||
weightModelObj,
|
||||
];
|
||||
WeightState copyWith({
|
||||
SelectionPopupModel? selectedDropDownValue,
|
||||
WeightModel? weightModelObj,
|
||||
}) {
|
||||
return WeightState(
|
||||
selectedDropDownValue:
|
||||
selectedDropDownValue ?? this.selectedDropDownValue,
|
||||
weightModelObj: weightModelObj ?? this.weightModelObj,
|
||||
);
|
||||
}
|
||||
}
|
||||
21
lib/presentation/weight_screen/models/weight_model.dart
Normal file
21
lib/presentation/weight_screen/models/weight_model.dart
Normal file
@@ -0,0 +1,21 @@
|
||||
// ignore_for_file: must_be_immutable
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:eatvio_app/data/models/selectionPopupModel/selection_popup_model.dart';
|
||||
|
||||
/// This class defines the variables used in the [weight_screen],
|
||||
/// and is typically used to hold data that is passed between different parts of the application.
|
||||
class WeightModel extends Equatable {
|
||||
WeightModel({this.dropdownItemList = const []}) {}
|
||||
|
||||
List<SelectionPopupModel> dropdownItemList;
|
||||
|
||||
WeightModel copyWith({List<SelectionPopupModel>? dropdownItemList}) {
|
||||
return WeightModel(
|
||||
dropdownItemList: dropdownItemList ?? this.dropdownItemList,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [dropdownItemList];
|
||||
}
|
||||
112
lib/presentation/weight_screen/weight_screen.dart
Normal file
112
lib/presentation/weight_screen/weight_screen.dart
Normal file
@@ -0,0 +1,112 @@
|
||||
import 'bloc/weight_bloc.dart';
|
||||
import 'models/weight_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/custom_outlined_button.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class WeightScreen extends StatelessWidget {
|
||||
const WeightScreen({Key? key}) : super(key: key);
|
||||
|
||||
static Widget builder(BuildContext context) {
|
||||
return BlocProvider<WeightBloc>(
|
||||
create: (context) =>
|
||||
WeightBloc(WeightState(weightModelObj: WeightModel()))
|
||||
..add(WeightInitialEvent()),
|
||||
child: WeightScreen());
|
||||
}
|
||||
|
||||
@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.35,
|
||||
backgroundColor: theme.colorScheme.onPrimary,
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
appTheme.blueA400)))),
|
||||
SizedBox(height: 39.v),
|
||||
_buildTwentySix(context),
|
||||
Spacer(),
|
||||
CustomOutlinedButton(text: "lbl2".tr.toUpperCase()),
|
||||
SizedBox(height: 17.v),
|
||||
Text("lbl3".tr, style: theme.textTheme.bodyLarge)
|
||||
]))));
|
||||
}
|
||||
|
||||
/// 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));
|
||||
}
|
||||
|
||||
/// Section Widget
|
||||
Widget _buildTwentySixWidget(BuildContext context) {
|
||||
return Column(children: [
|
||||
Text("lbl12".tr, style: theme.textTheme.bodyLarge),
|
||||
SizedBox(height: 4.v),
|
||||
BlocSelector<WeightBloc, WeightState, WeightModel?>(
|
||||
selector: (state) => state.weightModelObj,
|
||||
builder: (context, weightModelObj) {
|
||||
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: "lbl_70".tr,
|
||||
items: weightModelObj?.dropdownItemList ?? [],
|
||||
onChanged: (value) {
|
||||
context
|
||||
.read<WeightBloc>()
|
||||
.add(ChangeDropDownEvent(value: value));
|
||||
});
|
||||
})
|
||||
]);
|
||||
}
|
||||
|
||||
/// Section Widget
|
||||
Widget _buildTwentySix(BuildContext context) {
|
||||
return Column(children: [
|
||||
Text("lbl11".tr, style: theme.textTheme.headlineSmall),
|
||||
SizedBox(height: 174.v),
|
||||
_buildTwentySixWidget(context)
|
||||
]);
|
||||
}
|
||||
|
||||
/// Navigates to the previous screen.
|
||||
onTapArrowLeft(BuildContext context) {
|
||||
NavigatorService.goBack();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user