resource select, show only image when select

This commit is contained in:
Thomas Fransolet 2021-05-26 18:37:18 +02:00
parent b5387880b1
commit 5651022cce
3 changed files with 7 additions and 9 deletions

View File

@ -3,8 +3,6 @@ import 'package:flutter/material.dart';
import 'package:manager_app/Components/fetch_resource_icon.dart'; import 'package:manager_app/Components/fetch_resource_icon.dart';
import 'package:manager_app/Components/multi_select_container.dart'; import 'package:manager_app/Components/multi_select_container.dart';
import 'package:manager_app/Components/string_input_container.dart'; import 'package:manager_app/Components/string_input_container.dart';
import 'package:manager_app/Screens/Resources/new_resource_popup.dart';
import 'package:manager_app/Screens/Resources/show_resource_popup.dart';
import 'package:manager_app/app_context.dart'; import 'package:manager_app/app_context.dart';
import 'package:manager_app/constants.dart'; import 'package:manager_app/constants.dart';
import 'package:managerapi/api.dart'; import 'package:managerapi/api.dart';
@ -13,10 +11,12 @@ import 'package:provider/provider.dart';
class ResourceBodyGrid extends StatefulWidget { class ResourceBodyGrid extends StatefulWidget {
final List<ResourceDTO> resources; //return ResourceDTO final List<ResourceDTO> resources; //return ResourceDTO
final Function onSelect; final Function onSelect;
final bool isImage;
const ResourceBodyGrid({ const ResourceBodyGrid({
Key key, Key key,
this.resources, this.resources,
this.onSelect, this.onSelect,
this.isImage,
}) : super(key: key); }) : super(key: key);
@override @override
@ -67,7 +67,7 @@ class _ResourceBodyGridState extends State<ResourceBodyGrid> {
child: MultiSelectContainer( child: MultiSelectContainer(
label: "Type :", label: "Type :",
initialValue: filterType, initialValue: filterType,
values: resource_types, values: widget.isImage ? resource_types.where((type) => type != "video" && type != "video url").toList(): resource_types,
isMultiple: true, isMultiple: true,
onChanged: (result) { onChanged: (result) {
setState(() { setState(() {

View File

@ -15,7 +15,7 @@ class ResourcesScreen extends StatefulWidget {
final bool isImage; final bool isImage;
const ResourcesScreen({ const ResourcesScreen({
Key key, Key key,
this.isImage, this.isImage = false,
this.onGetResult, this.onGetResult,
}) : super(key: key); }) : super(key: key);
@ -37,9 +37,7 @@ class _ResourcesScreenState extends State<ResourcesScreen> {
if (snapshot.connectionState == ConnectionState.done) { if (snapshot.connectionState == ConnectionState.done) {
var tempOutput = new List<ResourceDTO>.from(snapshot.data); var tempOutput = new List<ResourceDTO>.from(snapshot.data);
// tempOutput.add(ResourceDTO(id: null)); // tempOutput.add(ResourceDTO(id: null));
return ResourceBodyGrid(resources: tempOutput, onSelect: (value) { return ResourceBodyGrid(resources: tempOutput, isImage: widget.isImage, onSelect: (value) {
print("result parent");
print(value);
if (widget.onGetResult == null) { if (widget.onGetResult == null) {
// Main screen // Main screen
if (value.id == null) { if (value.id == null) {

View File

@ -18,7 +18,7 @@ showSelectResourceModal (String text, Function onGetResult, int maxLines, bool o
child: Column( child: Column(
children: [ children: [
Container( Container(
width: size.width * 0.6, width: size.width * 0.7,
height: size.height * 0.75, height: size.height * 0.75,
child: ResourcesScreen( child: ResourcesScreen(
onGetResult: (ResourceDTO resource) { onGetResult: (ResourceDTO resource) {