Merge remote-tracking branch 'refs/remotes/origin/ui_ux_rollout_merge' into ui_ux_rollout_merge_notification_settings
commit
2a20b92c33
@ -0,0 +1,240 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:test_sa/dashboard_latest/dashboard_provider.dart';
|
||||
import 'package:test_sa/dashboard_latest/widgets/request_category_list.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/extensions/enum_extensions.dart';
|
||||
import 'package:test_sa/extensions/int_extensions.dart';
|
||||
import 'package:test_sa/extensions/string_extensions.dart';
|
||||
import 'package:test_sa/extensions/text_extensions.dart';
|
||||
import 'package:test_sa/extensions/widget_extensions.dart';
|
||||
import 'package:test_sa/models/enums/user_types.dart';
|
||||
import 'package:test_sa/models/new_models/dashboard_detail.dart';
|
||||
import 'package:test_sa/new_views/app_style/app_color.dart';
|
||||
import 'package:test_sa/new_views/common_widgets/tab_button.dart';
|
||||
import 'package:test_sa/views/widgets/loaders/no_data_found.dart';
|
||||
|
||||
/// Separate component for HouseKeeper role
|
||||
/// HouseKeeper has simpler requirements:
|
||||
/// - Single-select only (no multi-select)
|
||||
/// - Uses getRequestDetail API only
|
||||
/// - Default shows first category (In Progress)
|
||||
class RequestCategoryFragmentHouseKeeper extends StatefulWidget {
|
||||
const RequestCategoryFragmentHouseKeeper({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<RequestCategoryFragmentHouseKeeper> createState() => _RequestCategoryFragmentHouseKeeperState();
|
||||
}
|
||||
|
||||
class _RequestCategoryFragmentHouseKeeperState extends State<RequestCategoryFragmentHouseKeeper> with SingleTickerProviderStateMixin {
|
||||
bool isAscending = false;
|
||||
late AnimationController _animationController;
|
||||
late Animation<double> _headerFadeAnimation;
|
||||
late Animation<Offset> _headerSlideAnimation;
|
||||
final ScrollController _scrollController = ScrollController();
|
||||
// int _selectedIndex = 0; // Default first tab
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_animationController = AnimationController(
|
||||
duration: const Duration(milliseconds: 1200),
|
||||
vsync: this,
|
||||
);
|
||||
|
||||
// Header animation (appears first, faster)
|
||||
_headerFadeAnimation = Tween<double>(begin: 0.0, end: 1.0).animate(
|
||||
CurvedAnimation(
|
||||
parent: _animationController,
|
||||
curve: const Interval(0.0, 0.4, curve: Curves.easeOut),
|
||||
),
|
||||
);
|
||||
|
||||
_headerSlideAnimation = Tween<Offset>(
|
||||
begin: const Offset(0.0, -0.3),
|
||||
end: Offset.zero,
|
||||
).animate(
|
||||
CurvedAnimation(
|
||||
parent: _animationController,
|
||||
curve: const Interval(0.0, 0.5, curve: Curves.easeOutCubic),
|
||||
),
|
||||
);
|
||||
|
||||
_animationController.forward();
|
||||
|
||||
// Load first category data on init
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_loadCategoryData(0);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_animationController.dispose();
|
||||
_scrollController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
|
||||
void _loadCategoryData(int index) {
|
||||
final dashboardProvider = Provider.of<DashBoardProvider>(context, listen: false);
|
||||
List<CategoryTabs> tabs = CategoryTabs.getTabs(userType: UsersTypes.houseKeeper, context: context);
|
||||
|
||||
if (index >= 0 && index < tabs.length) {
|
||||
dashboardProvider.resetRequestDataList();
|
||||
dashboardProvider.getRequestDetail(
|
||||
usersType: UsersTypes.houseKeeper,
|
||||
showLoader: true,
|
||||
status: tabs[index].tag,
|
||||
tabId: tabs[index].id,
|
||||
isAscending: isAscending,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void _toggleSort(DashBoardProvider dashboardProvider) {
|
||||
setState(() {
|
||||
isAscending = !isAscending;
|
||||
});
|
||||
|
||||
// Reload current category with new sort order
|
||||
_loadCategoryData(dashboardProvider.currentListIndex!);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<DashBoardProvider>(builder: (context, dashboardProvider, child) {
|
||||
List<CategoryTabs> tabs = CategoryTabs.getTabs(userType: UsersTypes.houseKeeper, context: context);
|
||||
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
// Tabs
|
||||
_buildTabs(tabs, dashboardProvider),
|
||||
|
||||
// Header with sort
|
||||
FadeTransition(
|
||||
opacity: _headerFadeAnimation,
|
||||
child: SlideTransition(
|
||||
position: _headerSlideAnimation,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
'All Tasks'.addTranslation.heading4(context),
|
||||
Transform.flip(
|
||||
flipY: isAscending,
|
||||
child: 'dashboard/sort_descending'.toSvgAsset(
|
||||
width: 24,
|
||||
height: 24,
|
||||
color: AppColor.headingTextColor(context),
|
||||
).onPress(()=>_toggleSort(dashboardProvider)),
|
||||
)
|
||||
],
|
||||
).paddingOnly(start: 16, end: 16),
|
||||
),
|
||||
),
|
||||
|
||||
// Data list
|
||||
dashboardProvider.isDetailLoading
|
||||
? Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: List.generate(3, (index) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 10.toScreenHeight, horizontal: 0),
|
||||
child: const SizedBox().toRequestShimmer(context, dashboardProvider.isDetailLoading),
|
||||
);
|
||||
}),
|
||||
).paddingOnly(start: 16, end: 16, top: 16)
|
||||
: (dashboardProvider.requestDetailList == null || dashboardProvider.requestDetailList?.data?.isEmpty == true)
|
||||
? const NoDataFound().paddingOnly(top: 80).center
|
||||
: RequestCategoryList(
|
||||
dashboardProvider.requestDetailList?.data ?? <Data>[],
|
||||
dashboardProvider.isDetailLoading,
|
||||
dashboardProvider.requestDetailList?.totalRows ?? 0,
|
||||
),
|
||||
],
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Widget _buildTabs(List<CategoryTabs> tabs, DashBoardProvider dashboardProvider) {
|
||||
// Calculate item width
|
||||
final screenWidth = MediaQuery.of(context).size.width;
|
||||
final isTablet = context.isTablet();
|
||||
final visibleItemsWithPeek = isTablet ? 4.5 : 3.5;
|
||||
const spacing = 4.0;
|
||||
const horizontalPadding = 16.0;
|
||||
|
||||
final availableWidth = screenWidth - (horizontalPadding * 2);
|
||||
final fullItems = visibleItemsWithPeek.floor();
|
||||
final totalSpacing = (fullItems - 1) * spacing + (spacing * 0.5);
|
||||
final itemWidth = (availableWidth - totalSpacing) / visibleItemsWithPeek;
|
||||
|
||||
return SizedBox(
|
||||
height: itemWidth + 16,
|
||||
child: ListView.separated(
|
||||
controller: _scrollController,
|
||||
scrollDirection: Axis.horizontal,
|
||||
separatorBuilder: (cxt, index) => const SizedBox(width: 4),
|
||||
padding: const EdgeInsets.only(bottom: 16, left: horizontalPadding, right: horizontalPadding),
|
||||
itemBuilder: (cxt, index) {
|
||||
// Animation
|
||||
final delay = index * 0.08;
|
||||
final animation = Tween<double>(begin: 0.0, end: 1.0).animate(
|
||||
CurvedAnimation(
|
||||
parent: _animationController,
|
||||
curve: Interval(
|
||||
delay.clamp(0.0, 0.8),
|
||||
(delay + 0.3).clamp(0.0, 1.0),
|
||||
curve: Curves.easeOut,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final slideAnimation = Tween<Offset>(
|
||||
begin: const Offset(-0.3, 0.0),
|
||||
end: Offset.zero,
|
||||
).animate(
|
||||
CurvedAnimation(
|
||||
parent: _animationController,
|
||||
curve: Interval(
|
||||
delay.clamp(0.0, 0.8),
|
||||
(delay + 0.3).clamp(0.0, 1.0),
|
||||
curve: Curves.easeOutCubic,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return FadeTransition(
|
||||
opacity: animation,
|
||||
child: SlideTransition(
|
||||
position: slideAnimation,
|
||||
child: SizedBox(
|
||||
width: itemWidth,
|
||||
child: RequestTypeButton(
|
||||
label: tabs[index].label,
|
||||
loading: dashboardProvider.isDetailLoading && dashboardProvider.currentListIndex == index,
|
||||
isSelected: dashboardProvider.currentListIndex == index,
|
||||
count: dashboardProvider.getStatusCount(tabs[index].requestType),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
isAscending = false;
|
||||
// _selectedIndex = index;
|
||||
});
|
||||
dashboardProvider.currentListIndex = index;
|
||||
_loadCategoryData(index);
|
||||
},
|
||||
icon: tabs[index].icon,
|
||||
iconColor: tabs[index].iconColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
itemCount: tabs.length,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,11 @@
|
||||
class WoByAssetIdModel {
|
||||
int? id;
|
||||
String? workOrderNo;
|
||||
|
||||
WoByAssetIdModel({this.id, this.workOrderNo});
|
||||
|
||||
WoByAssetIdModel.fromJson(dynamic json) {
|
||||
id = json['id'];
|
||||
workOrderNo = json['workOrderNo'];
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,136 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:test_sa/controllers/providers/api/oracle_code_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/api/parts_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/api/user_provider.dart';
|
||||
import 'package:test_sa/controllers/providers/settings/setting_provider.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/extensions/int_extensions.dart';
|
||||
import 'package:test_sa/extensions/widget_extensions.dart';
|
||||
import 'package:test_sa/models/new_models/asset_nd_auto_complete_by_dynamic_codes_model.dart';
|
||||
import 'package:test_sa/models/wo_by_asset_id_model.dart';
|
||||
import 'package:test_sa/modules/cm_module/cm_detail_provider.dart';
|
||||
import 'package:test_sa/new_views/app_style/app_color.dart';
|
||||
import 'package:test_sa/views/app_style/sizing.dart';
|
||||
|
||||
import '../../../extensions/text_extensions.dart';
|
||||
import '../../../models/service_request/spare_parts.dart';
|
||||
import '../../../new_views/app_style/app_text_style.dart';
|
||||
|
||||
class WoAutoCompleteField extends StatefulWidget {
|
||||
final String initialValue;
|
||||
final int? assetId;
|
||||
final bool clearAfterPick, byName, enabled;
|
||||
final Function(WoByAssetIdModel) onPick;
|
||||
|
||||
const WoAutoCompleteField({Key? key, required this.byName, required this.initialValue, this.assetId, required this.onPick, this.clearAfterPick = true, this.enabled = true}) : super(key: key);
|
||||
|
||||
@override
|
||||
_WoAutoCompleteFieldState createState() => _WoAutoCompleteFieldState();
|
||||
}
|
||||
|
||||
class _WoAutoCompleteFieldState extends State<WoAutoCompleteField> {
|
||||
late CMDetailProvider _cmDetailProvider;
|
||||
|
||||
late TextEditingController _controller;
|
||||
|
||||
bool loading = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_controller = TextEditingController(text: widget.initialValue);
|
||||
super.initState();
|
||||
_cmDetailProvider = Provider.of<CMDetailProvider>(context, listen: false);
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant WoAutoCompleteField oldWidget) {
|
||||
if (widget.initialValue != oldWidget.initialValue) {
|
||||
_controller = TextEditingController(text: widget.initialValue);
|
||||
}
|
||||
super.didUpdateWidget(oldWidget);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final border = UnderlineInputBorder(borderSide: BorderSide.none, borderRadius: BorderRadius.circular(10));
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.background(context),
|
||||
borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
|
||||
// boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10)],
|
||||
),
|
||||
child: Autocomplete<WoByAssetIdModel>(
|
||||
optionsBuilder: (TextEditingValue textEditingValue) async {
|
||||
if (textEditingValue.text.isEmpty) {
|
||||
if (loading) {
|
||||
setState(() {
|
||||
loading = false;
|
||||
});
|
||||
}
|
||||
return const Iterable<WoByAssetIdModel>.empty();
|
||||
}
|
||||
if (!loading) {
|
||||
setState(() {
|
||||
loading = true;
|
||||
});
|
||||
}
|
||||
List<WoByAssetIdModel> workOrders = (await _cmDetailProvider.getWorkOrderByAssetId(textEditingValue.text, widget.assetId!));
|
||||
|
||||
setState(() {
|
||||
loading = false;
|
||||
});
|
||||
return workOrders;
|
||||
},
|
||||
displayStringForOption: (WoByAssetIdModel option) => widget.byName ? option.workOrderNo ?? "" : option.workOrderNo ?? "",
|
||||
fieldViewBuilder: (BuildContext context, TextEditingController fieldTextEditingController, FocusNode fieldFocusNode, VoidCallback onFieldSubmitted) {
|
||||
return TextField(
|
||||
controller: _controller,
|
||||
focusNode: fieldFocusNode,
|
||||
style: AppTextStyles.bodyText.copyWith(color: AppColor.black10),
|
||||
textAlign: TextAlign.start,
|
||||
decoration: InputDecoration(
|
||||
border: border,
|
||||
disabledBorder: border,
|
||||
focusedBorder: border,
|
||||
enabledBorder: border,
|
||||
errorBorder: border,
|
||||
contentPadding: EdgeInsets.symmetric(vertical: 8.toScreenHeight, horizontal: 16.toScreenWidth),
|
||||
constraints: const BoxConstraints(),
|
||||
suffixIconConstraints: const BoxConstraints(maxHeight: 24, maxWidth: 24 + 8),
|
||||
filled: true,
|
||||
enabled: widget.enabled,
|
||||
fillColor: AppColor.fieldBgColor(context),
|
||||
errorStyle: AppTextStyle.tiny.copyWith(color: context.isDark ? AppColor.red50 : AppColor.red60),
|
||||
floatingLabelStyle: AppTextStyle.body1.copyWith(fontWeight: FontWeight.w500, color: context.isDark ? null : AppColor.neutral20),
|
||||
labelText: "CM Work Order Number",
|
||||
labelStyle: AppTextStyles.tinyFont.copyWith(color: AppColor.textColor(context)),
|
||||
suffixIcon: loading ? const CircularProgressIndicator(color: AppColor.primary10, strokeWidth: 3.0).paddingOnly(end: 8) : null,
|
||||
),
|
||||
textInputAction: TextInputAction.search,
|
||||
onChanged: (text) {
|
||||
fieldTextEditingController.text = text;
|
||||
},
|
||||
onSubmitted: (String value) {
|
||||
onFieldSubmitted();
|
||||
},
|
||||
);
|
||||
},
|
||||
onSelected: (WoByAssetIdModel selection) {
|
||||
if (widget.clearAfterPick) {
|
||||
_controller.clear();
|
||||
} else {
|
||||
_controller.text = widget.byName ? (selection.workOrderNo ?? "") : (selection.workOrderNo ?? "");
|
||||
}
|
||||
widget.onPick(selection);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue