Merge pull request 'refactor_for_demo' (#27) from refactor_for_demo into main
Reviewed-on: https://repo.ravanertebat.com/TM/tm_app/pulls/27
This commit is contained in:
@@ -7,6 +7,7 @@ import 'package:tm_app/core/theme/colors.dart';
|
||||
import 'package:tm_app/core/utils/size_config.dart';
|
||||
import 'package:tm_app/view_models/tender_detail_view_model.dart';
|
||||
import 'package:tm_app/views/detail/widgets/tender_detail_action.dart';
|
||||
import 'package:tm_app/views/detail/widgets/tender_detail_card.dart';
|
||||
import 'package:tm_app/views/detail/widgets/tender_detail_header.dart';
|
||||
|
||||
class TenderDetailDesktopPage extends StatefulWidget {
|
||||
@@ -62,6 +63,8 @@ class _TenderDetailDesktopPageState extends State<TenderDetailDesktopPage> {
|
||||
children: [
|
||||
TenderDetailHeader(isScreenBig: true, detail: detail),
|
||||
SizedBox(height: 32.0.h()),
|
||||
TenderDetailCard(detail: detail),
|
||||
SizedBox(height: 24.0.h()),
|
||||
TenderDetailActions(isScreenBig: true),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:tm_app/core/theme/colors.dart';
|
||||
import 'package:tm_app/core/utils/size_config.dart';
|
||||
import 'package:tm_app/view_models/tender_detail_view_model.dart';
|
||||
import 'package:tm_app/views/detail/widgets/tender_detail_action.dart';
|
||||
import 'package:tm_app/views/detail/widgets/tender_detail_card.dart';
|
||||
import 'package:tm_app/views/detail/widgets/tender_detail_header.dart';
|
||||
|
||||
class TenderDetailMobilePage extends StatefulWidget {
|
||||
@@ -15,19 +16,18 @@ class TenderDetailMobilePage extends StatefulWidget {
|
||||
|
||||
@override
|
||||
State<TenderDetailMobilePage> createState() => _TenderDetailMobilePageState();
|
||||
|
||||
}
|
||||
|
||||
|
||||
class _TenderDetailMobilePageState extends State<TenderDetailMobilePage> {
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
Future.microtask(() {
|
||||
context.read<TenderDetailViewModel>().getTenderDetail(id: widget.tenderId);
|
||||
});
|
||||
}
|
||||
void initState() {
|
||||
super.initState();
|
||||
Future.microtask(() {
|
||||
context.read<TenderDetailViewModel>().getTenderDetail(
|
||||
id: widget.tenderId,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -59,6 +59,8 @@ void initState() {
|
||||
children: [
|
||||
TenderDetailHeader(isScreenBig: false, detail: detail),
|
||||
SizedBox(height: 24.0.h()),
|
||||
TenderDetailCard(detail: detail),
|
||||
SizedBox(height: 24.0.h()),
|
||||
TenderDetailActions(isScreenBig: false),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:tm_app/core/theme/colors.dart';
|
||||
import 'package:tm_app/core/utils/size_config.dart';
|
||||
import 'package:tm_app/view_models/tender_detail_view_model.dart';
|
||||
import 'package:tm_app/views/detail/widgets/tender_detail_action.dart';
|
||||
import 'package:tm_app/views/detail/widgets/tender_detail_card.dart';
|
||||
import 'package:tm_app/views/detail/widgets/tender_detail_header.dart';
|
||||
|
||||
class TenderDetailTabletPage extends StatefulWidget {
|
||||
@@ -61,6 +62,8 @@ class _TenderDetailTabletPageState extends State<TenderDetailTabletPage> {
|
||||
children: [
|
||||
TenderDetailHeader(isScreenBig: true, detail: detail),
|
||||
SizedBox(height: 28.0.h()),
|
||||
TenderDetailCard(detail: detail),
|
||||
SizedBox(height: 24.0.h()),
|
||||
TenderDetailActions(isScreenBig: true),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -99,7 +99,7 @@ class DeadlineItem extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
SizedBox(height: 8.0.h()),
|
||||
const Divider(),
|
||||
Divider(color: AppColors.grey20,),
|
||||
],
|
||||
),
|
||||
)
|
||||
@@ -163,7 +163,7 @@ class DeadlineItem extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
SizedBox(height: 8.0.h()),
|
||||
const Divider(),
|
||||
Divider(color: AppColors.grey20,),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -35,7 +35,7 @@ class InfoItem extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
SizedBox(height: 8.0.h()),
|
||||
const Divider(),
|
||||
Divider(color: AppColors.grey20,),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:tm_app/core/constants/strings.dart';
|
||||
import 'package:tm_app/core/theme/colors.dart';
|
||||
import 'package:tm_app/core/utils/size_config.dart';
|
||||
import 'package:tm_app/views/login/widgets/login_button.dart';
|
||||
import 'package:tm_app/views/shared/base_button.dart';
|
||||
|
||||
class TenderDetailActions extends StatelessWidget {
|
||||
final bool isScreenBig;
|
||||
@@ -28,7 +28,7 @@ class TenderDetailActions extends StatelessWidget {
|
||||
isEnabled: true,
|
||||
text: AppStrings.tenderSubmitButton,
|
||||
backgroundColor: AppColors.lightBlue,
|
||||
textColor: AppColors.mainBlue,
|
||||
textColor: AppColors.primary30,
|
||||
onPressed: () {},
|
||||
width: 120.0.w(),
|
||||
),
|
||||
@@ -39,7 +39,7 @@ class TenderDetailActions extends StatelessWidget {
|
||||
BaseButton(
|
||||
isEnabled: true,
|
||||
text: AppStrings.tenderSubmitButton,
|
||||
backgroundColor: AppColors.lightBlue,
|
||||
backgroundColor: AppColors.primary30,
|
||||
textColor: AppColors.mainBlue,
|
||||
onPressed: () {},
|
||||
),
|
||||
|
||||
@@ -2,9 +2,12 @@ import 'package:flutter/material.dart';
|
||||
import 'package:tm_app/core/constants/strings.dart';
|
||||
import 'package:tm_app/core/theme/colors.dart';
|
||||
import 'package:tm_app/core/utils/size_config.dart';
|
||||
import 'package:tm_app/data/services/model/tender_detail_response/tender_detail_response_model.dart';
|
||||
|
||||
class TenderDetailCard extends StatelessWidget {
|
||||
const TenderDetailCard({super.key});
|
||||
final TenderDetailResponseModel detail;
|
||||
|
||||
const TenderDetailCard({required this.detail, super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -13,6 +16,7 @@ class TenderDetailCard extends StatelessWidget {
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.paleOrange,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: AppColors.veryPaleOrange),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
|
||||
@@ -29,7 +29,7 @@ class TenderDetailHeader extends StatelessWidget {
|
||||
SizedBox(height: 12.0.h()),
|
||||
_buildTitle(),
|
||||
SizedBox(height: 10.0.h()),
|
||||
const Divider(),
|
||||
Divider(color: AppColors.grey20,),
|
||||
SizedBox(height: 5.0.h()),
|
||||
TenderDetailInfoSection(isScreenBig: isScreenBig, detail: detail),
|
||||
TenderLocationSection(detail: detail),
|
||||
|
||||
@@ -9,7 +9,7 @@ import 'package:tm_app/data/services/model/tender_detail_response/tender_detail_
|
||||
class TenderLocationSection extends StatelessWidget {
|
||||
final TenderDetailResponseModel detail;
|
||||
|
||||
const TenderLocationSection({super.key, required this.detail});
|
||||
const TenderLocationSection({required this.detail, super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
@@ -20,68 +20,90 @@ class LoginDesktopPage extends StatelessWidget {
|
||||
body: Center(
|
||||
child: SingleChildScrollView(
|
||||
padding: EdgeInsets.symmetric(horizontal: 24.0.w()),
|
||||
child: SizedBox(
|
||||
width: 526,
|
||||
child: Consumer<AuthViewModel>(
|
||||
builder: (context, viewModel, _) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
LoginLogo(width: 190.0.w(), height: 88.0.h()),
|
||||
SizedBox(height: 32.0.h()),
|
||||
const LoginTitle(),
|
||||
SizedBox(height: 32.0.h()),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 526,
|
||||
child: Consumer<AuthViewModel>(
|
||||
builder: (context, viewModel, _) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
LoginLogo(width: 190.0.w(), height: 88.0.h()),
|
||||
SizedBox(height: 32.0.h()),
|
||||
const LoginTitle(),
|
||||
SizedBox(height: 32.0.h()),
|
||||
LoginTextField(
|
||||
controller: viewModel.usernameController,
|
||||
focusNode: viewModel.usernameFocus,
|
||||
label: AppStrings.usernameLabel,
|
||||
iconPath: AssetsManager.userIcon,
|
||||
fieldHeight: 60.0.h(),
|
||||
borderRedus: 12,
|
||||
prefixIconPadding: 7.0.w(),
|
||||
),
|
||||
SizedBox(height: 16.0.h()),
|
||||
LoginTextField(
|
||||
controller: viewModel.passwordController,
|
||||
focusNode: viewModel.passwordFocus,
|
||||
label: AppStrings.passwordLabel,
|
||||
iconPath: AssetsManager.passwordIcon,
|
||||
prefixIconPadding: 7.0.w(),
|
||||
isPassword: true,
|
||||
obscureText: viewModel.obscurePassword,
|
||||
fieldHeight: 60.0.h(),
|
||||
onToggleVisibility:
|
||||
viewModel.togglePasswordVisibility,
|
||||
borderRedus: 12,
|
||||
),
|
||||
SizedBox(height: 32.0.h()),
|
||||
|
||||
LoginTextField(
|
||||
controller: viewModel.usernameController,
|
||||
focusNode: viewModel.usernameFocus,
|
||||
label: AppStrings.usernameLabel,
|
||||
iconPath: AssetsManager.userIcon,
|
||||
fieldHeight: 60.0.h(),
|
||||
borderRedus: 4.0.w(),
|
||||
prefixIconPadding: 4.0.w(),
|
||||
),
|
||||
SizedBox(height: 16.0.h()),
|
||||
|
||||
LoginTextField(
|
||||
controller: viewModel.passwordController,
|
||||
focusNode: viewModel.passwordFocus,
|
||||
label: AppStrings.passwordLabel,
|
||||
iconPath: AssetsManager.passwordIcon,
|
||||
prefixIconPadding: 4.0.w(),
|
||||
isPassword: true,
|
||||
obscureText: viewModel.obscurePassword,
|
||||
fieldHeight: 60.0.h(),
|
||||
onToggleVisibility: viewModel.togglePasswordVisibility,
|
||||
borderRedus: 4.0.w(),
|
||||
),
|
||||
SizedBox(height: 32.0.h()),
|
||||
|
||||
if (viewModel.isLoading)
|
||||
const CircularProgressIndicator()
|
||||
else
|
||||
BaseButton(
|
||||
isEnabled: viewModel.isLoginEnabled,
|
||||
onPressed:
|
||||
viewModel.isLoginEnabled
|
||||
? () async {
|
||||
await viewModel.login();
|
||||
if (viewModel.loggedInUser != null) {
|
||||
HomeRouteData().go(context);
|
||||
} else if (viewModel.errorMessage != null) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(viewModel.errorMessage!),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
: null,
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
if (viewModel.isLoading)
|
||||
BaseButton(
|
||||
isEnabled: false,
|
||||
onPressed: null,
|
||||
isLoading: true,
|
||||
)
|
||||
else
|
||||
BaseButton(
|
||||
isEnabled: viewModel.isLoginEnabled,
|
||||
onPressed:
|
||||
viewModel.isLoginEnabled
|
||||
? () async {
|
||||
await viewModel.login();
|
||||
if (viewModel.loggedInUser != null) {
|
||||
HomeRouteData().go(context);
|
||||
} else if (viewModel.errorMessage !=
|
||||
null) {
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
viewModel.errorMessage!,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
: null,
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 20.0.h()),
|
||||
child: Image.asset(
|
||||
AssetsManager.webLoginImage,
|
||||
width: 796.0.w(),
|
||||
height: 944.0.h(),
|
||||
fit: BoxFit.fitHeight,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -49,7 +49,12 @@ class LoginMobilePage extends StatelessWidget {
|
||||
SizedBox(height: 32.0.h()),
|
||||
|
||||
if (viewModel.isLoading)
|
||||
const CircularProgressIndicator()
|
||||
BaseButton(
|
||||
isEnabled: false,
|
||||
onPressed: null,
|
||||
isLoading: true,
|
||||
textColor: AppColors.white,
|
||||
)
|
||||
else
|
||||
BaseButton(
|
||||
isEnabled: viewModel.isLoginEnabled,
|
||||
|
||||
@@ -38,7 +38,7 @@ class LoginTabletPage extends StatelessWidget {
|
||||
label: AppStrings.usernameLabel,
|
||||
iconPath: AssetsManager.userIcon,
|
||||
fieldHeight: 60.0.h(),
|
||||
borderRedus: 4.0.w(),
|
||||
borderRedus: 12,
|
||||
prefixIconPadding: 4.0.w(),
|
||||
),
|
||||
SizedBox(height: 16.0.h()),
|
||||
@@ -53,12 +53,16 @@ class LoginTabletPage extends StatelessWidget {
|
||||
obscureText: viewModel.obscurePassword,
|
||||
fieldHeight: 60.0.h(),
|
||||
onToggleVisibility: viewModel.togglePasswordVisibility,
|
||||
borderRedus: 4.0.w(),
|
||||
borderRedus: 12,
|
||||
),
|
||||
SizedBox(height: 32.0.h()),
|
||||
|
||||
if (viewModel.isLoading)
|
||||
const CircularProgressIndicator()
|
||||
BaseButton(
|
||||
isEnabled: false,
|
||||
onPressed: null,
|
||||
isLoading: true,
|
||||
)
|
||||
else
|
||||
BaseButton(
|
||||
isEnabled: viewModel.isLoginEnabled,
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/constants/strings.dart';
|
||||
import '../../../core/theme/colors.dart';
|
||||
import '../../../core/utils/size_config.dart';
|
||||
|
||||
class BaseButton extends StatelessWidget {
|
||||
final bool isEnabled;
|
||||
final VoidCallback? onPressed;
|
||||
final String? text;
|
||||
final Color? textColor;
|
||||
final Color? backgroundColor;
|
||||
final Color? borderColor;
|
||||
final double? borderWidth;
|
||||
final double? borderRadius;
|
||||
final double? elevation;
|
||||
final double? width;
|
||||
|
||||
const BaseButton({
|
||||
required this.isEnabled,
|
||||
required this.onPressed,
|
||||
this.text,
|
||||
this.textColor,
|
||||
this.backgroundColor,
|
||||
this.borderColor,
|
||||
this.borderWidth,
|
||||
this.borderRadius,
|
||||
this.elevation,
|
||||
this.width,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
width: width ?? double.infinity,
|
||||
height: 55.0.h(),
|
||||
child: ElevatedButton(
|
||||
onPressed: isEnabled ? onPressed : null,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor:
|
||||
backgroundColor ??
|
||||
(isEnabled ? AppColors.mainBlue : AppColors.backgroundColor),
|
||||
foregroundColor: textColor ?? AppColors.backgroundColor,
|
||||
elevation: elevation ?? 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(borderRadius ?? 28.0.w()),
|
||||
side: BorderSide(
|
||||
color: borderColor ?? Colors.transparent,
|
||||
width: borderWidth ?? 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
text ?? AppStrings.loginButton,
|
||||
style: TextStyle(
|
||||
fontSize: 16.0.sp(),
|
||||
fontWeight: FontWeight.bold,
|
||||
color: textColor ?? AppColors.backgroundColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
export 'login_button.dart';
|
||||
export '../../shared/base_button.dart';
|
||||
export 'login_logo.dart';
|
||||
export 'login_textfield.dart';
|
||||
export 'login_title.dart';
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../core/constants/strings.dart';
|
||||
import '../../core/theme/colors.dart';
|
||||
import '../../core/utils/size_config.dart';
|
||||
|
||||
class BaseButton extends StatelessWidget {
|
||||
final bool isEnabled;
|
||||
final VoidCallback? onPressed;
|
||||
final String? text;
|
||||
final Color? textColor;
|
||||
final Color? backgroundColor;
|
||||
final Color? borderColor;
|
||||
final double? borderWidth;
|
||||
final double? borderRadius;
|
||||
final double? elevation;
|
||||
final double? width;
|
||||
final bool isLoading;
|
||||
|
||||
const BaseButton({
|
||||
required this.isEnabled,
|
||||
required this.onPressed,
|
||||
this.text,
|
||||
this.textColor,
|
||||
this.backgroundColor,
|
||||
this.borderColor,
|
||||
this.borderWidth,
|
||||
this.borderRadius,
|
||||
this.elevation,
|
||||
this.width,
|
||||
this.isLoading = false,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return isLoading
|
||||
? Container(
|
||||
width: double.infinity,
|
||||
height: 55.0.h(),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.mainBlue,
|
||||
borderRadius: BorderRadius.circular(28.0.w()),
|
||||
),
|
||||
child: Center(
|
||||
child: SizedBox(
|
||||
width: 30.0.w(),
|
||||
height: 30.0.w(),
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 4.0,
|
||||
color: AppColors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
: SizedBox(
|
||||
width: width ?? double.infinity,
|
||||
height: 55.0.h(),
|
||||
child: ElevatedButton(
|
||||
onPressed: isEnabled ? onPressed : null,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor:
|
||||
backgroundColor ??
|
||||
(isEnabled ? AppColors.mainBlue : AppColors.backgroundColor),
|
||||
foregroundColor: textColor ?? AppColors.backgroundColor,
|
||||
elevation: elevation ?? 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(borderRadius ?? 28.0.w()),
|
||||
side: BorderSide(
|
||||
color: borderColor ?? Colors.transparent,
|
||||
width: borderWidth ?? 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
text ?? AppStrings.loginButton,
|
||||
style: TextStyle(
|
||||
fontSize: 16.0.sp(),
|
||||
fontWeight: FontWeight.bold,
|
||||
color: textColor ?? AppColors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user