Compare commits
4 Commits
3c182b856d
...
e65d2a44ed
| Author | SHA1 | Date |
|---|---|---|
|
|
e65d2a44ed | 2 years ago |
|
|
9a1303fc5e | 2 years ago |
|
|
a9fb22583e | 2 years ago |
|
|
3cc7176c63 | 2 years ago |
@ -0,0 +1,3 @@
|
|||||||
|
<svg width="283" height="283" viewBox="0 0 283 283" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path opacity="0.1" d="M53.0625 66.3281V123.812H35.375V66.3281H53.0625ZM35.375 159.188V216.672H53.0625V159.188H35.375ZM128.234 66.3281V123.812H145.922V66.3281H128.234ZM128.234 159.188V216.672H145.922V159.188H128.234ZM229.938 66.3281V123.812H247.625V66.3281H229.938ZM229.938 159.188V216.672H247.625V159.188H229.938ZM88.4375 66.3281V123.812H97.2812V66.3281H88.4375ZM88.4375 159.188V216.672H97.2812V159.188H88.4375ZM106.125 66.3281V123.812H114.969V66.3281H106.125ZM106.125 159.188V216.672H114.969V159.188H106.125ZM185.719 66.3281V123.812H194.562V66.3281H185.719ZM185.719 159.188V216.672H194.562V159.188H185.719ZM203.406 66.3281V123.812H212.25V66.3281H203.406ZM203.406 159.188V216.672H212.25V159.188H203.406ZM66.3281 66.3281V123.812H79.5938V66.3281H66.3281ZM66.3281 159.188V216.672H79.5938V159.188H66.3281ZM159.188 66.3281V123.812H172.453V66.3281H159.188ZM159.188 159.188V216.672H172.453V159.188H159.188ZM269.734 132.656H13.2656V150.344H269.734V132.656ZM17.6875 48.6406H57.4844V39.7969H8.84375V88.4375H17.6875V48.6406ZM274.156 39.7969H225.516V48.6406H265.312V88.4375H274.156V39.7969ZM57.4844 234.359H17.6875V194.562H8.84375V243.203H57.4844V234.359ZM274.156 194.562H265.312V234.359H225.516V243.203H274.156V194.562Z" fill="white"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.3 KiB |
@ -0,0 +1,43 @@
|
|||||||
|
import 'package:flutter/material.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 '../app_style/app_color.dart';
|
||||||
|
|
||||||
|
class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||||
|
final String title;
|
||||||
|
final List<Widget> actions;
|
||||||
|
final double bottomCorner;
|
||||||
|
|
||||||
|
const CustomAppBar({this.title, this.actions, this.bottomCorner, Key key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return AppBar(
|
||||||
|
automaticallyImplyLeading: false,
|
||||||
|
titleSpacing: 16,
|
||||||
|
title: Row(
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.arrow_back_ios).onPress(() {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
}),
|
||||||
|
Text(
|
||||||
|
title ?? "",
|
||||||
|
style: AppTextStyles.heading3?.copyWith(fontWeight: FontWeight.w600, color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
|
||||||
|
).expanded,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
actions: actions,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.vertical(
|
||||||
|
bottom: Radius.circular(bottomCorner??10),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Size get preferredSize => Size.fromHeight(60.toScreenHeight);
|
||||||
|
}
|
||||||
@ -0,0 +1,195 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import 'package:test_sa/controllers/providers/api/devices_provider.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/common_widgets/app_text_form_field.dart';
|
||||||
|
|
||||||
|
import '../../../models/device/asset.dart';
|
||||||
|
import '../../../models/device/asset_search.dart';
|
||||||
|
import '../../../new_views/app_style/app_color.dart';
|
||||||
|
import '../../../new_views/common_widgets/app_lazy_loading.dart';
|
||||||
|
import '../../../new_views/common_widgets/custom_app_bar.dart';
|
||||||
|
import '../../widgets/equipment/asset_item_listview.dart';
|
||||||
|
import '../../widgets/horizontal_list_widget.dart';
|
||||||
|
import '../../widgets/loaders/lazy_loading.dart';
|
||||||
|
import '../../widgets/loaders/no_item_found.dart';
|
||||||
|
|
||||||
|
class SearchAssetPage extends StatefulWidget {
|
||||||
|
/// add on route
|
||||||
|
static const String id = "asset_search_page";
|
||||||
|
|
||||||
|
const SearchAssetPage({Key key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<SearchAssetPage> createState() => _SearchAssetPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SearchAssetPageState extends State<SearchAssetPage> {
|
||||||
|
int _selectedIndex = 0;
|
||||||
|
AssetSearch search;
|
||||||
|
TextEditingController _searchController;
|
||||||
|
AssetProvider _deviceProvider;
|
||||||
|
List<Asset> _searchableList = [];
|
||||||
|
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
||||||
|
bool _isFirst = true;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
_searchController = TextEditingController();
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_searchController?.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
List<String> searchBy = [
|
||||||
|
context.translation.assetName,
|
||||||
|
context.translation.assetNumber,
|
||||||
|
context.translation.oracleCode,
|
||||||
|
context.translation.snNumber,
|
||||||
|
];
|
||||||
|
|
||||||
|
_deviceProvider = Provider.of<AssetProvider>(context, listen: false);
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
resizeToAvoidBottomInset: false,
|
||||||
|
appBar: CustomAppBar(
|
||||||
|
title: context.translation.searchAsset,
|
||||||
|
|
||||||
|
/// comment reset button because it isn't exist in new design
|
||||||
|
// actions: [
|
||||||
|
// if (_showResetButton())
|
||||||
|
// Row(
|
||||||
|
// crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
// children: [
|
||||||
|
// Text(
|
||||||
|
// context.translation.reset,
|
||||||
|
// style: AppTextStyles.bodyText2.copyWith(color: const Color(0xFF4A8DB7)),
|
||||||
|
// ).paddingAll(8).onPress(() {
|
||||||
|
// setState(() {
|
||||||
|
// _searchController.text = "";
|
||||||
|
// });
|
||||||
|
// }),
|
||||||
|
// ],
|
||||||
|
// )
|
||||||
|
// ],
|
||||||
|
),
|
||||||
|
body: Column(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
flex: 2,
|
||||||
|
child: HorizontalListWidget(
|
||||||
|
list: searchBy,
|
||||||
|
callBackFunction: (index) {
|
||||||
|
setState(() {
|
||||||
|
_selectedIndex = index;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
).paddingOnly(top: 16),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
flex: 3,
|
||||||
|
child: Form(
|
||||||
|
key: _formKey,
|
||||||
|
child: AppTextFormField(
|
||||||
|
controller: _searchController,
|
||||||
|
labelText: "${context.translation.searchBy} ${searchBy[_selectedIndex]}",
|
||||||
|
onChange: (text) {
|
||||||
|
_searchController.text = text;
|
||||||
|
_searchController.selection = TextSelection.fromPosition(TextPosition(offset: _searchController.text.length));
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
onSaved: (value) {
|
||||||
|
setState(() {
|
||||||
|
search = AssetSearch();
|
||||||
|
});
|
||||||
|
_setValue(value);
|
||||||
|
},
|
||||||
|
suffixIcon: IconButton(
|
||||||
|
icon: const Icon(Icons.search),
|
||||||
|
onPressed: _searchController.text.isNotEmpty ? _search : null,
|
||||||
|
color: AppColor.neutral20,
|
||||||
|
).paddingOnly(end: 6),
|
||||||
|
).paddingOnly(top: 18, start: 18, end: 18),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
flex: 25,
|
||||||
|
child: _searchableList.isEmpty
|
||||||
|
? _isFirst
|
||||||
|
? const SizedBox()
|
||||||
|
: NoItemFound(message: context.translation.noDeviceFound)
|
||||||
|
: LazyLoading(
|
||||||
|
nextPage: _deviceProvider.nextPage,
|
||||||
|
onLazyLoad: () async {
|
||||||
|
if (_searchController.text.isNotEmpty) {
|
||||||
|
await _deviceProvider.getAssets(search: search, isSearchBy: true);
|
||||||
|
setState(() {
|
||||||
|
_searchableList.clear();
|
||||||
|
_searchableList.addAll(_deviceProvider.searchDevices);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: ListView.separated(
|
||||||
|
itemCount: _searchableList.length,
|
||||||
|
separatorBuilder: (listContext, itemIndex) => 8.height,
|
||||||
|
itemBuilder: (listContext, itemIndex) {
|
||||||
|
return AssetItemListView(
|
||||||
|
device: _searchableList[itemIndex],
|
||||||
|
onPressed: (device) {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
Navigator.of(context).pop(device);
|
||||||
|
},
|
||||||
|
selectButton: Text(context.translation.select, style: AppTextStyles.bodyText.copyWith(color: AppColor.blueStatus(context))),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
).paddingOnly(start: 16, end: 16),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
void _search() async {
|
||||||
|
FocusScope.of(context).unfocus();
|
||||||
|
_formKey.currentState.save();
|
||||||
|
_deviceProvider.searchReset();
|
||||||
|
showDialog(context: context, barrierDismissible: false, builder: (context) => const AppLazyLoading());
|
||||||
|
await _deviceProvider.getAssets(search: search, isSearchBy: true);
|
||||||
|
setState(() {
|
||||||
|
_searchableList.clear();
|
||||||
|
_searchableList.addAll(_deviceProvider.searchDevices);
|
||||||
|
_isFirst = false;
|
||||||
|
});
|
||||||
|
Navigator.pop(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
_setValue(value) {
|
||||||
|
/// todo : check oracle code (no matched parameter)
|
||||||
|
switch (_selectedIndex) {
|
||||||
|
case 0:
|
||||||
|
search.assetName = value;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
search.assetNo = value;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
search.assetSerialNumber = value;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// bool _showResetButton() {
|
||||||
|
// return (_searchController?.text?.isNotEmpty ?? false);
|
||||||
|
// }
|
||||||
|
}
|
||||||
@ -0,0 +1,51 @@
|
|||||||
|
import 'package:flutter/material.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 '../../new_views/app_style/app_color.dart';
|
||||||
|
|
||||||
|
class HorizontalListWidget extends StatefulWidget {
|
||||||
|
const HorizontalListWidget({Key key, @required this.list,this.callBackFunction}) : super(key: key);
|
||||||
|
final List<String> list;
|
||||||
|
final Function(int index) callBackFunction;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<HorizontalListWidget> createState() => _HorizontalListWidgetState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _HorizontalListWidgetState extends State<HorizontalListWidget> {
|
||||||
|
int _selectedIndex = 0;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return SizedBox(
|
||||||
|
height: 35.toScreenHeight,
|
||||||
|
child: ListView.builder(
|
||||||
|
itemCount: widget.list.length,
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
shrinkWrap: true,
|
||||||
|
padding: EdgeInsetsDirectional.only(start: 16.toScreenWidth),
|
||||||
|
itemBuilder: (context, index) => Container(
|
||||||
|
margin: EdgeInsets.symmetric(horizontal: 4.toScreenWidth),
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 20.toScreenWidth),
|
||||||
|
alignment: Alignment.center,
|
||||||
|
decoration: ShapeDecoration(
|
||||||
|
color: _selectedIndex == index ? Colors.transparent : AppColor.selectedButtonColor(context),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
side: _selectedIndex == index ? BorderSide(width: 2, color: (context.isDark ? AppColor.backgroundLight : AppColor.backgroundDark)) : BorderSide.none,
|
||||||
|
borderRadius: BorderRadius.circular(7),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: (widget.list[index]).tinyFont(context).custom(color: AppColor.filterButtonTextColor(context)),
|
||||||
|
).onPress(() {
|
||||||
|
setState(() {
|
||||||
|
_selectedIndex = index;
|
||||||
|
});
|
||||||
|
widget.callBackFunction?.call(index);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,118 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import 'package:qr_code_scanner/qr_code_scanner.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 '../../../controllers/providers/api/devices_provider.dart';
|
||||||
|
import '../../../models/device/asset_search.dart';
|
||||||
|
import '../../../new_views/common_widgets/app_filled_button.dart';
|
||||||
|
import '../../../new_views/common_widgets/custom_app_bar.dart';
|
||||||
|
import '../../pages/device_transfer/search_asset_page.dart';
|
||||||
|
|
||||||
|
class AssetScanQr extends StatefulWidget {
|
||||||
|
static const String id = "/asset-scan-qr";
|
||||||
|
|
||||||
|
const AssetScanQr({Key key, this.title}) : super(key: key);
|
||||||
|
final String title;
|
||||||
|
|
||||||
|
@override
|
||||||
|
_AssetScanQrState createState() => _AssetScanQrState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _AssetScanQrState extends State<AssetScanQr> {
|
||||||
|
Barcode result;
|
||||||
|
QRViewController _controller;
|
||||||
|
bool _scanDone = false;
|
||||||
|
final GlobalKey qrKey = GlobalKey(debugLabel: 'QR_scanner');
|
||||||
|
AssetProvider _devicesProvider;
|
||||||
|
|
||||||
|
// In order to get hot reload to work we need to pause the camera if the platform
|
||||||
|
// is android, or resume the camera if the platform is iOS.
|
||||||
|
@override
|
||||||
|
void reassemble() {
|
||||||
|
super.reassemble();
|
||||||
|
if (Platform.isAndroid) {
|
||||||
|
_controller?.pauseCamera();
|
||||||
|
} else if (Platform.isIOS) {
|
||||||
|
_controller?.resumeCamera();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
super.dispose();
|
||||||
|
_controller?.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
_pickManually() async {
|
||||||
|
await Navigator.push(context, MaterialPageRoute(builder: (context) => const SearchAssetPage()));
|
||||||
|
}
|
||||||
|
|
||||||
|
_getDevice(String result, {bool isQr = false}) async {
|
||||||
|
if (result == null) return;
|
||||||
|
_devicesProvider.reset();
|
||||||
|
await _devicesProvider.getAssets(
|
||||||
|
search: AssetSearch(assetNo: result, assetSerialNumber: ""),
|
||||||
|
isQr: isQr,
|
||||||
|
);
|
||||||
|
return _devicesProvider.devices;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
_devicesProvider = Provider.of<AssetProvider>(context);
|
||||||
|
return Scaffold(
|
||||||
|
body: SafeArea(
|
||||||
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
QRView(
|
||||||
|
key: qrKey,
|
||||||
|
onQRViewCreated: (QRViewController controller) {
|
||||||
|
setState(() {
|
||||||
|
_controller = controller;
|
||||||
|
});
|
||||||
|
controller.scannedDataStream.listen((scanData) async {
|
||||||
|
if (!_scanDone) {
|
||||||
|
_scanDone = true;
|
||||||
|
final result = await _getDevice(scanData.code, isQr: true);
|
||||||
|
Navigator.of(context).pop(result[0]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
Center(
|
||||||
|
child: 'scan'.toSvgAsset(
|
||||||
|
height: 283.toScreenHeight.toInt(),
|
||||||
|
width: 283.toScreenWidth.toInt(),
|
||||||
|
fit: BoxFit.fitHeight,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 60.toScreenHeight,
|
||||||
|
child: CustomAppBar(
|
||||||
|
title: widget.title,
|
||||||
|
)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
bottomSheet: Container(
|
||||||
|
height: 82.toScreenHeight,
|
||||||
|
color: Colors.white,
|
||||||
|
width: MediaQuery.of(context).size.width,
|
||||||
|
child: Center(
|
||||||
|
child: SizedBox(
|
||||||
|
height: 50.toScreenHeight,
|
||||||
|
width: 358.toScreenWidth,
|
||||||
|
child: AppFilledButton(
|
||||||
|
label: context.translation.pickManually,
|
||||||
|
onPressed: _pickManually,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue