test
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
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/main.dart';
|
||||
import 'package:oc_front/models/search.dart';
|
||||
import 'package:oc_front/pages/abstract_page.dart';
|
||||
import 'package:oc_front/pages/catalog.dart';
|
||||
@@ -9,19 +10,21 @@ import 'package:oc_front/widgets/items/item_row.dart';
|
||||
|
||||
class CatalogItemFactory implements AbstractFactory {
|
||||
static GlobalKey<CatalogItemPageWidgetState> key = GlobalKey<CatalogItemPageWidgetState>();
|
||||
@override void clear() { }
|
||||
@override GlobalKey getKey() { return key; }
|
||||
@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);
|
||||
var item = CatalogFactory.key.currentState?.widget.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) { }
|
||||
@override void search(BuildContext context, bool special) { }
|
||||
}
|
||||
|
||||
class CatalogItemPageWidget extends StatefulWidget {
|
||||
@@ -32,7 +35,7 @@ class CatalogItemPageWidget extends StatefulWidget {
|
||||
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,),
|
||||
ItemRowWidget(contextWidth: getMainWidth(context), item: widget.item, readOnly: true,),
|
||||
ItemWidget(item: widget.item,),
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user