oc-search porting to flutter (missing compose + workflow editor)
This commit is contained in:
40
lib/pages/catalog.dart
Normal file
40
lib/pages/catalog.dart
Normal file
@@ -0,0 +1,40 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:oc_front/models/search.dart';
|
||||
import 'package:oc_front/widgets/catalog.dart';
|
||||
import 'package:oc_front/pages/abstract_page.dart';
|
||||
import 'package:oc_front/core/sections/header/search.dart';
|
||||
import 'package:oc_front/core/services/specialized_services/search_service.dart';
|
||||
|
||||
class CatalogFactory implements AbstractFactory {
|
||||
static List<AbstractItem> items = [];
|
||||
static GlobalKey<CatalogPageWidgetState> key = GlobalKey<CatalogPageWidgetState>();
|
||||
@override bool searchFill() { return CatalogFactory.items.isEmpty; }
|
||||
@override Widget factory(GoRouterState state, List<String> args) { return CatalogPageWidget(); }
|
||||
@override void search(BuildContext context) {
|
||||
CatalogFactory.key.currentState?.widget.search.get(context, SearchConstants.get()!).then((value) {
|
||||
if (value.data == null) { return; }
|
||||
CatalogFactory.items = [
|
||||
...value.data!.computing, ...value.data!.data, ...value.data!.storage, ...value.data!.datacenter,];
|
||||
searchWidgetKey.currentState?.setState(() {});
|
||||
CatalogFactory.key.currentState?.setState(() {});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class CatalogPageWidget extends StatefulWidget {
|
||||
final SearchService search = SearchService();
|
||||
CatalogPageWidget (): super(key: CatalogFactory.key);
|
||||
@override CatalogPageWidgetState createState() => CatalogPageWidgetState();
|
||||
}
|
||||
class CatalogPageWidgetState extends State<CatalogPageWidget> {
|
||||
@override Widget build(BuildContext context) {
|
||||
return Column( children : [
|
||||
SizedBox(
|
||||
width: MediaQuery.of(context).size.width,
|
||||
height: CatalogFactory.items.isEmpty ? 0 : MediaQuery.of(context).size.height - 200,
|
||||
child: CatalogWidget(items: CatalogFactory.items) )
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user