add [pm date range] & [equipment status] to asset filter
parent
6258035a88
commit
32e54d6853
@ -0,0 +1,3 @@
|
||||
<svg width="20" height="19" viewBox="0 0 20 19" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M19.2188 1.52321H16.25V0.801688C16.25 0.358916 15.9002 0 15.4688 0C15.0373 0 14.6875 0.358916 14.6875 0.801688V1.52321H10.7812V0.801688C10.7812 0.358916 10.4315 0 10 0C9.56852 0 9.21875 0.358916 9.21875 0.801688V1.52321H5.3125V0.801688C5.3125 0.358916 4.96273 0 4.53125 0C4.09977 0 3.75 0.358916 3.75 0.801688V1.52321H0.78125C0.349766 1.52321 0 1.88212 0 2.32489V18.1983C0 18.6411 0.349766 19 0.78125 19H19.2188C19.6502 19 20 18.6411 20 18.1983V2.32489C20 1.88212 19.6502 1.52321 19.2188 1.52321ZM18.4375 17.3966H1.5625V7.85654H18.4375V17.3966ZM18.4375 6.25316H1.5625V3.12658H3.75V3.8481C3.75 4.29087 4.09977 4.64979 4.53125 4.64979C4.96273 4.64979 5.3125 4.29087 5.3125 3.8481V3.12658H9.21875V3.8481C9.21875 4.29087 9.56852 4.64979 10 4.64979C10.4315 4.64979 10.7812 4.29087 10.7812 3.8481V3.12658H14.6875V3.8481C14.6875 4.29087 15.0373 4.64979 15.4688 4.64979C15.9002 4.64979 16.25 4.29087 16.25 3.8481V3.12658H18.4375V6.25316Z" fill="#163A51"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.0 KiB |
@ -1,35 +1,54 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:test_sa/views/app_style/sizing.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/extensions/int_extensions.dart';
|
||||
import 'package:test_sa/extensions/text_extensions.dart';
|
||||
import 'package:test_sa/extensions/widget_extensions.dart';
|
||||
import 'package:test_sa/new_views/app_style/app_color.dart';
|
||||
|
||||
class ADatePicker extends StatelessWidget {
|
||||
final DateTime date;
|
||||
final DateTime from;
|
||||
final DateTime to;
|
||||
final String label;
|
||||
final Function(DateTime) onDatePicker;
|
||||
final bool enable;
|
||||
|
||||
const ADatePicker({Key key, this.date, this.onDatePicker, this.from, this.to, this.enable = true}) : super(key: key);
|
||||
const ADatePicker({Key key, @required this.label, this.date, this.onDatePicker, this.from, this.to, this.enable = true}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
foregroundColor: Colors.white,
|
||||
textStyle: Theme.of(context).textTheme.subtitle2,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12 * AppStyle.getScaleFactor(context)),
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(width: 1, color: Theme.of(context).scaffoldBackgroundColor),
|
||||
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.05), blurRadius: 10)],
|
||||
),
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.toScreenWidth, vertical: 8.toScreenHeight),
|
||||
child: Row(
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
label.tinyFont(context),
|
||||
(date?.toIso8601String() ?? context.translation.pickDate).bodyText(context).custom(color: AppColor.neutral50),
|
||||
],
|
||||
).expanded,
|
||||
16.width,
|
||||
"calender".toSvgAsset(width: 20),
|
||||
],
|
||||
),
|
||||
onPressed: enable
|
||||
).onPress(enable
|
||||
? () async {
|
||||
DateTime picked = await showDatePicker(context: context, initialDate: DateTime.now(), firstDate: from ?? DateTime.now(), lastDate: to ?? DateTime.now().add(Duration(days: 365)));
|
||||
DateTime picked = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: DateTime.now(),
|
||||
firstDate: from ?? DateTime.now(),
|
||||
lastDate: to ?? DateTime.now().add(const Duration(days: 365)),
|
||||
);
|
||||
onDatePicker(picked);
|
||||
}
|
||||
: null,
|
||||
child: Text(
|
||||
date == null ? "Pick Date" : date.toString().split(" ").first,
|
||||
textScaleFactor: AppStyle.getScaleFactor(context),
|
||||
),
|
||||
);
|
||||
: null);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,102 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:shimmer/shimmer.dart';
|
||||
import 'package:test_sa/extensions/context_extension.dart';
|
||||
import 'package:test_sa/extensions/int_extensions.dart';
|
||||
import 'package:test_sa/extensions/text_extensions.dart';
|
||||
import 'package:test_sa/extensions/widget_extensions.dart';
|
||||
|
||||
import '../../../models/lookup.dart';
|
||||
import '../../../new_views/app_style/app_color.dart';
|
||||
import '../../../providers/service_request_providers/equipment_status_provider.dart';
|
||||
|
||||
class EquipmentStatusButtons extends StatefulWidget {
|
||||
final Function(Lookup) onSelect;
|
||||
const EquipmentStatusButtons({Key key, this.onSelect}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<EquipmentStatusButtons> createState() => _EquipmentStatusButtonsState();
|
||||
}
|
||||
|
||||
class _EquipmentStatusButtonsState extends State<EquipmentStatusButtons> {
|
||||
int _selectedEquipmentStatusIndex = 0;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
WidgetsFlutterBinding.ensureInitialized().addPostFrameCallback((timeStamp) {
|
||||
Provider.of<EquipmentStatusProvider>(context, listen: false).getDate();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
context.translation.equipmentStatus.heading5(context).paddingOnly(start: 16, end: 16),
|
||||
8.height,
|
||||
Consumer<EquipmentStatusProvider>(
|
||||
builder: (context, snapshot, _) {
|
||||
return snapshot.loading
|
||||
? Shimmer(
|
||||
gradient: const LinearGradient(colors: [AppColor.primary40, AppColor.primary50, AppColor.primary60]),
|
||||
child: Row(
|
||||
children: [
|
||||
const _Skelton().expanded,
|
||||
8.width,
|
||||
const _Skelton().expanded,
|
||||
8.width,
|
||||
const _Skelton().expanded,
|
||||
],
|
||||
).paddingOnly(start: 16, end: 16),
|
||||
)
|
||||
: SizedBox(
|
||||
height: 36.toScreenHeight,
|
||||
child: ListView.builder(
|
||||
itemCount: snapshot.items.length + 1,
|
||||
scrollDirection: Axis.horizontal,
|
||||
shrinkWrap: true,
|
||||
padding: EdgeInsetsDirectional.only(start: 16.toScreenWidth),
|
||||
itemBuilder: (context, index) => Container(
|
||||
margin: EdgeInsets.symmetric(horizontal: 4.toScreenWidth),
|
||||
padding: EdgeInsets.symmetric(vertical: 8.toScreenHeight, horizontal: (_selectedEquipmentStatusIndex == index ? 12 : 8).toScreenWidth),
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(7),
|
||||
color: _selectedEquipmentStatusIndex == index ? AppColor.neutral30 : Colors.white,
|
||||
border: _selectedEquipmentStatusIndex == index ? Border.all(width: 1, color: AppColor.primary50) : null,
|
||||
boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.03), blurRadius: 14)],
|
||||
),
|
||||
child: (index == 0 ? "All Assets" : snapshot.items[index - 1].name).tinyFont(context).custom(color: AppColor.neutral50),
|
||||
).onPress(() {
|
||||
setState(() {
|
||||
_selectedEquipmentStatusIndex = index;
|
||||
});
|
||||
widget.onSelect(index == 0 ? null : snapshot.items[index - 1]);
|
||||
}),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _Skelton extends StatelessWidget {
|
||||
const _Skelton({
|
||||
Key key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.neutral50.withOpacity(0.05),
|
||||
borderRadius: BorderRadius.circular(7),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue