oc-search porting to flutter (missing compose + workflow editor)
This commit is contained in:
39
lib/pages/catalog_item.dart
Normal file
39
lib/pages/catalog_item.dart
Normal file
@@ -0,0 +1,39 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:oc_front/core/models/cart.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 ?? "");
|
||||
if (item != null) { return CatalogItemPageWidget(item : item); }
|
||||
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,),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user