Major Change Inputs & Co
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:localstorage/localstorage.dart';
|
||||
import 'package:oc_front/core/models/workspace_local.dart';
|
||||
import 'package:oc_front/core/sections/header/header.dart';
|
||||
import 'package:oc_front/core/services/router.dart';
|
||||
import 'package:oc_front/main.dart';
|
||||
import 'package:oc_front/models/search.dart';
|
||||
import 'package:oc_front/models/resources/resources.dart';
|
||||
import 'package:oc_front/pages/abstract_page.dart';
|
||||
import 'package:oc_front/pages/catalog.dart';
|
||||
import 'package:oc_front/widgets/items/item.dart';
|
||||
@@ -11,6 +14,13 @@ import 'package:oc_front/widgets/items/item_row.dart';
|
||||
class CatalogItemFactory implements AbstractFactory {
|
||||
static GlobalKey<CatalogItemPageWidgetState> key = GlobalKey<CatalogItemPageWidgetState>();
|
||||
@override GlobalKey getKey() { return key; }
|
||||
@override void back(BuildContext context) {
|
||||
search(context, false);
|
||||
}
|
||||
@override String? getSearch() {
|
||||
if ((localStorage.getItem("search") ?? "") == "") { return null; }
|
||||
return localStorage.getItem("search")!.split(",")[0];
|
||||
}
|
||||
@override bool searchFill() { return false; }
|
||||
@override Widget factory(GoRouterState state, List<String> args) {
|
||||
var id = state.pathParameters[args.first];
|
||||
@@ -19,13 +29,22 @@ class CatalogItemFactory implements AbstractFactory {
|
||||
return CatalogItemPageWidget(item : item!);
|
||||
} catch (e) {
|
||||
var item = WorkspaceLocal.getItem(id ?? "", false);
|
||||
if (item != null) { return CatalogItemPageWidget(item : item as AbstractItem); }
|
||||
if (item != null) { return CatalogItemPageWidget(item : item); }
|
||||
return Container();
|
||||
}
|
||||
}
|
||||
@override void search(BuildContext context, bool special) { }
|
||||
@override void search(BuildContext context, bool special) {
|
||||
if (special) { return; } // T
|
||||
var s = SearchConstants.get();
|
||||
AppRouter.catalog.go(context, {});
|
||||
Future.delayed(Duration(milliseconds: 10), () {
|
||||
SearchConstants.set(s);
|
||||
CatalogFactory().search(context, false);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class CatalogItemPageWidget extends StatefulWidget {
|
||||
AbstractItem item;
|
||||
CatalogItemPageWidget ({ required this.item }) : super(key: CatalogItemFactory.key);
|
||||
@@ -35,7 +54,7 @@ class CatalogItemPageWidgetState extends State<CatalogItemPageWidget> {
|
||||
@override Widget build(BuildContext context) {
|
||||
return Column( children: [
|
||||
ItemRowWidget(contextWidth: getMainWidth(context), item: widget.item, readOnly: true,),
|
||||
ItemWidget(item: widget.item,),
|
||||
ItemWidget(item: widget.item),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user