You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
178 lines
7.9 KiB
Dart
178 lines
7.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:test_sa/controllers/api_routes/urls.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/models/device/asset_by_id_model.dart';
|
|
import 'package:test_sa/new_views/common_widgets/default_app_bar.dart';
|
|
import 'package:test_sa/views/widgets/loaders/app_loading.dart';
|
|
import 'package:test_sa/views/widgets/loaders/failed_loading.dart';
|
|
import 'package:test_sa/views/widgets/loaders/lazy_loading.dart';
|
|
import 'package:test_sa/views/widgets/loaders/loading_manager.dart';
|
|
|
|
class AssetDetailPage extends StatefulWidget {
|
|
static const String id = "/asset-details";
|
|
|
|
AssetDetailPage({Key key}) : super(key: key);
|
|
|
|
@override
|
|
_AssetDetailPageState createState() {
|
|
return _AssetDetailPageState();
|
|
}
|
|
}
|
|
|
|
class _AssetDetailPageState extends State<AssetDetailPage> {
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
super.dispose();
|
|
}
|
|
|
|
int assetId;
|
|
AssetProvider _assetProvider;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
assetId ??= ModalRoute.of(context).settings.arguments;
|
|
_assetProvider ??= Provider.of<AssetProvider>(context);
|
|
_assetProvider?.stateCode = null;
|
|
return Scaffold(
|
|
appBar: DefaultAppBar(title: context.translation.assetDetails),
|
|
body: FutureBuilder<AssetByIdModel>(
|
|
future: _assetProvider.getAssetById(assetId, context.translation),
|
|
builder: (BuildContext context, AsyncSnapshot<AssetByIdModel> snapshot) {
|
|
if (snapshot.hasError) {
|
|
return FailedLoading(
|
|
message: snapshot.error.toString(),
|
|
onReload: () {
|
|
setState(() {});
|
|
},
|
|
);
|
|
}
|
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
|
return const Center(child: ALoading());
|
|
} else if (snapshot.hasData) {}
|
|
if (snapshot.hasData) {
|
|
return SingleChildScrollView(
|
|
padding: const EdgeInsets.all(16),
|
|
child: Container(
|
|
padding: const EdgeInsets.all(16),
|
|
decoration: ShapeDecoration(
|
|
color: Colors.white,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(20),
|
|
),
|
|
shadows: const [BoxShadow(color: Color(0x07000000), blurRadius: 14, offset: Offset(0, 0), spreadRadius: 0)],
|
|
),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
AspectRatio(
|
|
aspectRatio: 159 / 94,
|
|
child: Container(
|
|
width: 95,
|
|
height: 95,
|
|
decoration: ShapeDecoration(
|
|
color: const Color(0xFFEAF1F4),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(10),
|
|
),
|
|
image: DecorationImage(
|
|
fit: BoxFit.cover,
|
|
image: NetworkImage(
|
|
_assetProvider.assetById?.assetPhoto != null ? URLs.getFileUrl(_assetProvider.assetById.assetPhoto) : "https://www.lasteelcraft.com/images/no-image-available.png"),
|
|
)),
|
|
),
|
|
),
|
|
6.height,
|
|
Column(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
_assetProvider.assetById?.modelDefinition?.assetName ?? "-",
|
|
style: AppTextStyles.heading5.copyWith(color: Color(0xFF3B3D4A)),
|
|
),
|
|
8.height,
|
|
Text(
|
|
"${context.translation.assetNumber}: ${_assetProvider.assetById.multiAssets.first.assetNumber}",
|
|
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
|
|
),
|
|
Text(
|
|
"${context.translation.model}: ${_assetProvider.assetById.modelDefinition.modelDefCode}",
|
|
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
|
|
),
|
|
Text(
|
|
"${context.translation.serialNo}: ${_assetProvider.assetById.multiAssets.first.assetSerialNo}",
|
|
maxLines: 2,
|
|
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
|
|
),
|
|
Text(
|
|
"MD: ${_assetProvider.assetById.department.departmentName ?? "-"}",
|
|
maxLines: 2,
|
|
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
|
|
),
|
|
Text(
|
|
"Supplier: ${_assetProvider.assetById.supplier?.suppliername ?? "-"}",
|
|
maxLines: 2,
|
|
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
|
|
),
|
|
Text(
|
|
"Manufacturer: ${_assetProvider.assetById.modelDefinition.manufacturerName}",
|
|
maxLines: 2,
|
|
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
|
|
),
|
|
Text(
|
|
"Location: ${_assetProvider.assetById.site.custName}",
|
|
maxLines: 2,
|
|
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
|
|
),
|
|
8.height,
|
|
const Divider(color: Color(0xFFEAF1F4), height: 1, thickness: 1),
|
|
8.height,
|
|
Text(
|
|
"Installation Date: ${_assetProvider.assetById.installationDate ?? "-"}",
|
|
maxLines: 2,
|
|
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
|
|
),
|
|
Text(
|
|
"Next PM Date: ${_assetProvider.assetById.installationDate ?? "-"}",
|
|
maxLines: 2,
|
|
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
|
|
),
|
|
Text(
|
|
"Last PM Date: ${_assetProvider.assetById.installationDate ?? "-"}",
|
|
maxLines: 2,
|
|
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
|
|
),
|
|
if ((_assetProvider.assetById.modelDefinition.assetDescription ?? "").isNotEmpty) ...[
|
|
8.height,
|
|
const Divider(color: Color(0xFFEAF1F4), height: 1, thickness: 1),
|
|
8.height,
|
|
Text(
|
|
_assetProvider.assetById.modelDefinition.assetDescription ?? "-",
|
|
maxLines: 2,
|
|
style: AppTextStyles.bodyText.copyWith(color: Color(0xFF757575)),
|
|
),
|
|
]
|
|
],
|
|
)
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
return Center(child: ALoading());
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|