39 lines
1.6 KiB
Dart
39 lines
1.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
import 'package:oc_front/core/models/workspace_local.dart';
|
|
import 'package:oc_front/models/search.dart';
|
|
import 'package:oc_front/pages/abstract_page.dart';
|
|
import 'package:oc_front/pages/catalog.dart';
|
|
import 'package:oc_front/widgets/items/item.dart';
|
|
import 'package:oc_front/widgets/items/item_row.dart';
|
|
|
|
class CatalogItemFactory implements AbstractFactory {
|
|
static GlobalKey<CatalogItemPageWidgetState> key = GlobalKey<CatalogItemPageWidgetState>();
|
|
@override bool searchFill() { return false; }
|
|
@override Widget factory(GoRouterState state, List<String> args) {
|
|
var id = state.pathParameters[args.first];
|
|
try {
|
|
var item = CatalogFactory.items.firstWhere( (element) => element.id == id );
|
|
return CatalogItemPageWidget(item : item);
|
|
} catch (e) {
|
|
var item = WorkspaceLocal.getItem(id ?? "", false);
|
|
if (item != null) { return CatalogItemPageWidget(item : item as AbstractItem); }
|
|
return Container();
|
|
}
|
|
}
|
|
@override void search(BuildContext context) { }
|
|
}
|
|
|
|
class CatalogItemPageWidget extends StatefulWidget {
|
|
AbstractItem item;
|
|
CatalogItemPageWidget ({ required this.item }) : super(key: CatalogItemFactory.key);
|
|
@override CatalogItemPageWidgetState createState() => CatalogItemPageWidgetState();
|
|
}
|
|
class CatalogItemPageWidgetState extends State<CatalogItemPageWidget> {
|
|
@override Widget build(BuildContext context) {
|
|
return Column( children: [
|
|
ItemRowWidget(contextWidth: MediaQuery.of(context).size.width, item: widget.item, readOnly: true,),
|
|
ItemWidget(item: widget.item,),
|
|
]);
|
|
}
|
|
} |