Remove add resource for dispose + fixed sized windows + get result as function modal + fix bugs

This commit is contained in:
Thomas Fransolet 2021-07-27 17:39:37 +02:00
parent fe6fe9edc5
commit b4a4d21c56
20 changed files with 268 additions and 203 deletions

View File

@ -46,12 +46,12 @@ class _GeoPointImageListState extends State<GeoPointImageList> {
@override
Widget build(BuildContext context) {
final appContext = Provider.of<AppContext>(context);
Size size = MediaQuery.of(context).size;
//Size size = MediaQuery.of(context).size;
return Stack(
children: [
Padding(
padding: const EdgeInsets.only(left: 10.0, right: 10.0, bottom: 10.0, top: 15.0),
padding: const EdgeInsets.only(left: 15.0, right: 15.0, bottom: 15.0, top: 15.0),
child: ReorderableListView(
onReorder: _onReorder,
scrollDirection: Axis.horizontal,
@ -88,19 +88,23 @@ class _GeoPointImageListState extends State<GeoPointImageList> {
bottom: 10,
right: 10,
child: InkWell(
onTap: () {
showSelectResourceModal(
onTap: () async {
var result = await showSelectResourceModal(
"Sélectionner une ressource",
(ResourceDTO resource) {
setState(() {
ImageGeoPoint newImage = new ImageGeoPoint( imageResourceId: resource.id, imageSource: resource.type == ResourceType.imageUrl ? resource.data : appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ resource.id);
imagesGeo.add(newImage);
});
},
1,
true,
context
);
if (result != null) {
setState(() {
ImageGeoPoint newImage = new ImageGeoPoint(imageResourceId: result.id, imageSource: result.type == ResourceType.imageUrl ? result.data : appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ result.id);
print("REULT IMAGES = ");
print(newImage);
imagesGeo.add(newImage);
print(imagesGeo);
widget.onChanged(imagesGeo);
});
}
},
child: Container(
height: MediaQuery.of(context).size.width * 0.04,

View File

@ -5,7 +5,7 @@ import 'package:manager_app/Components/fetch_section_icon.dart';
import 'package:manager_app/Components/image_input_container.dart';
import 'package:manager_app/Components/multi_select_container.dart';
import 'package:manager_app/Components/slider_input_container.dart';
import 'file:///C:/Users/Thomas%20Fransolet/Documents/Documents/Perso/MuseeDeLaFraise/manager-app/lib/Screens/Configurations/Section/SubSection/Map/showNewOrUpdateGeoPoint.dart';
import 'package:manager_app/Screens/Configurations/Section/SubSection/Map/showNewOrUpdateGeoPoint.dart';
import 'package:manager_app/app_context.dart';
import 'package:manager_app/constants.dart';
import 'package:managerapi/api.dart';
@ -71,6 +71,7 @@ class _MapConfigState extends State<MapConfig> {
mapDTO.iconResourceId = resource.id;
widget.onChanged(jsonEncode(mapDTO).toString());
},
isSmall: true
),
// Map Type
MultiSelectContainer(

View File

@ -133,8 +133,10 @@ void showNewOrUpdateGeoPoint(GeoPointDTO inputGeoPointDTO, Function getResult, A
color: kPrimaryColor,
textColor: kWhite,
press: () {
if (geoPointDTO.latitude != null && geoPointDTO.longitude != null) {
getResult(geoPointDTO);
Navigator.of(context).pop();
}
},
fontSize: 20,
),

View File

@ -71,18 +71,19 @@ class _ListViewCard extends State<ListViewCardImage> {
child: Row(
children: [
InkWell(
onTap: () {
showNewOrUpdateImageSlider(
onTap: () async {
var result = await showNewOrUpdateImageSlider(
widget.listItems[widget.index],
(value) {
setState(() {
widget.listItems[widget.index] = value;
widget.onChanged(widget.listItems);
});
},
widget.appContext,
context
);
if (result != null) {
setState(() {
widget.listItems[widget.index] = result;
widget.onChanged(widget.listItems);
});
}
},
child: Padding(
padding: const EdgeInsets.all(8.0),
@ -122,7 +123,7 @@ boxDecoration(ImageDTO imageDTO, appContext) {
shape: BoxShape.rectangle,
border: Border.all(width: 1.5, color: kSecond),
borderRadius: BorderRadius.circular(10.0),
image: imageDTO.title != null ? new DecorationImage(
image: imageDTO.title != null && imageDTO.source_ != null ? new DecorationImage(
fit: BoxFit.scaleDown,
image: new NetworkImage(
imageDTO.source_,

View File

@ -8,7 +8,7 @@ import 'package:manager_app/app_context.dart';
import 'package:manager_app/constants.dart';
import 'package:managerapi/api.dart';
void showNewOrUpdateImageSlider(ImageDTO inputImageDTO, Function getResult, AppContext appContext, BuildContext context) {
Future<ImageDTO> showNewOrUpdateImageSlider(ImageDTO inputImageDTO, AppContext appContext, BuildContext context) async {
ImageDTO imageDTO = new ImageDTO();
if (inputImageDTO != null) {
@ -28,7 +28,7 @@ void showNewOrUpdateImageSlider(ImageDTO inputImageDTO, Function getResult, AppC
}
Size size = MediaQuery.of(context).size;
showDialog(
var result = await showDialog(
builder: (BuildContext dialogContext) => AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(20.0))
@ -49,8 +49,9 @@ void showNewOrUpdateImageSlider(ImageDTO inputImageDTO, Function getResult, AppC
initialValue: imageDTO.resourceId,
color: kPrimaryColor,
onChanged: (ResourceDTO resource) {
imageDTO.source_ = resource.type == ResourceType.imageUrl ? resource.data : appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ resource.id;
imageDTO.resourceId = resource.id;
var result = resource;
imageDTO.source_ = result.type == ResourceType.imageUrl ? result.data : appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ result.id;
imageDTO.resourceId = result.id;
},
),
),
@ -82,7 +83,7 @@ void showNewOrUpdateImageSlider(ImageDTO inputImageDTO, Function getResult, AppC
icon: Icons.undo,
color: kSecond,
press: () {
Navigator.of(dialogContext).pop();
Navigator.pop(dialogContext);
},
fontSize: 20,
),
@ -100,8 +101,7 @@ void showNewOrUpdateImageSlider(ImageDTO inputImageDTO, Function getResult, AppC
textColor: kWhite,
press: () {
if (imageDTO.resourceId != null) {
getResult(imageDTO);
Navigator.of(dialogContext).pop();
Navigator.pop(dialogContext, imageDTO);
}
},
fontSize: 20,
@ -113,6 +113,8 @@ void showNewOrUpdateImageSlider(ImageDTO inputImageDTO, Function getResult, AppC
],
), context: context
);
return result;
}
getTranslations(BuildContext context, AppContext appContext, ImageDTO imageDTO) {

View File

@ -42,7 +42,7 @@ class _SliderConfigState extends State<SliderConfig> {
@override
Widget build(BuildContext context) {
final appContext = Provider.of<AppContext>(context);
Size size = MediaQuery.of(context).size;
//Size size = MediaQuery.of(context).size;
void _onReorder(int oldIndex, int newIndex) {
setState(
@ -97,24 +97,17 @@ class _SliderConfigState extends State<SliderConfig> {
bottom: 0,
right: 0,
child: InkWell(
onTap: () {
showNewOrUpdateImageSlider(
null,
(ImageDTO image) {
print("get result bébé showNewOrUpdateImageSlider");
if (this.mounted) {
onTap: () async {
var result = await showNewOrUpdateImageSlider(null, appContext, context);
if (result != null)
{
setState(() {
image.order = sliderDTO.images.length;
sliderDTO.images.add(image);
result.order = sliderDTO.images.length;
sliderDTO.images.add(result);
widget.onChanged(jsonEncode(sliderDTO).toString());
});
} else {
print("DISPOSE MEEEEERDE");
}
},
appContext,
context);
},
child: Container(
height: MediaQuery.of(context).size.width * 0.04,
width: MediaQuery.of(context).size.width * 0.04,

View File

@ -40,7 +40,18 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
future: getSection(widget.id, appContext.getContext().clientAPI),
builder: (context, AsyncSnapshot<dynamic> snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
return bodySection(snapshot.data, size, appContext, context);
return Stack(
children: [
bodySection(snapshot.data, size, appContext, context),
Align(
alignment: AlignmentDirectional.bottomCenter,
child: Container(
height: 80,
child: getButtons(sectionDTO, appContext),
),
)
],
);
} else if (snapshot.connectionState == ConnectionState.none) {
return Text("No data");
} else {
@ -57,10 +68,10 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
Widget bodySection(SectionDTO sectionDTO, Size size, AppContext appContext, BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Container(
height: size.height *0.13,
//height: size.height *0.13,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
@ -117,9 +128,6 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
),
), // TITLE
Container(
/*height: size.height*0.4,
color: Colors.lightBlue,*/
//height: size.height *0.1,
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Container(
@ -142,24 +150,8 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
sectionDTO.label = value;
},
),
ImageInputContainer(
label: "Image :",
initialValue: sectionDTO != null ? sectionDTO.imageId : "",
color: kPrimaryColor,
onChanged: (ResourceDTO resource) {
print("received value in grant older");
sectionDTO.imageId = resource.id;
sectionDTO.imageSource = resource.type == ResourceType.imageUrl ? resource.data : appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ resource.id;
},
),
],
),
Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
MultiStringContainer(
label: "Titre :",
label: "Titre affiché:",
modalLabel: "Titre",
color: kPrimaryColor,
initialValue: sectionDTO != null ? sectionDTO.title : [],
@ -172,7 +164,7 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
maxLines: 1,
),
MultiStringContainer(
label: "Description :",
label: "Description affichée:",
modalLabel: "Description",
color: kPrimaryColor,
initialValue: sectionDTO != null ? sectionDTO.description : [],
@ -183,6 +175,22 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
}
},
maxLines: 2,
),
],
),
Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ImageInputContainer(
label: "Image :",
initialValue: sectionDTO != null ? sectionDTO.imageId : "",
color: kPrimaryColor,
onChanged: (ResourceDTO resource) {
print("received value in grant older");
sectionDTO.imageId = resource.id;
sectionDTO.imageSource = resource.type == ResourceType.imageUrl ? resource.data : appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ resource.id;
},
)
],
)
@ -195,8 +203,8 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
),
),// FIELDS SECTION
Container(
height: size.height * 0.305,
width: size.width * 0.8,
//height: size.height * 0.305,
//width: size.width * 0.8,
child: Padding(
padding: const EdgeInsets.all(10.0),
child: sectionDTO != null ? getSpecificData(sectionDTO, appContext) : null,
@ -206,7 +214,9 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
border: Border.all(width: 1.5, color: kSecond)
),
),
getButtons(sectionDTO, appContext),
SizedBox(
height: size.height*0.1,
)
],
);
}
@ -285,6 +295,8 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
Future<void> save(bool isTraduction, SectionDTO sectionDTO, AppContext appContext) async {
print("SAVE");
print(sectionDTO);
if (sectionDTO != null) {
SectionDTO section = await appContext.getContext().clientAPI.sectionApi.sectionUpdate(sectionDTO);
ManagerAppContext managerAppContext = appContext.getContext();
managerAppContext.selectedSection = section;
@ -296,6 +308,7 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
showNotification(Colors.green, kWhite, 'La section a été sauvegardée avec succès', context);
}
}
}
getSpecificData(SectionDTO sectionDTO, AppContext appContext) {
switch(sectionDTO.type) {
@ -303,17 +316,15 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
return MapConfig(
initialValue: sectionDTO.data,
onChanged: (String data) {
print("Received info in parent");
print(data);
sectionDTO.data = data;
save(false, sectionDTO, appContext);
},
);
case SectionType.slider:
return SliderConfig(
initialValue: sectionDTO.data,
onChanged: (String data) {
print("Received info in parent");
print(data);
sectionDTO.data = data;
},
);

View File

@ -1,5 +1,4 @@
import 'package:flutter/material.dart';
import 'package:manager_app/Components/loading.dart';
import 'package:manager_app/Components/rounded_button.dart';
import 'package:manager_app/Components/string_input_container.dart';
import 'package:manager_app/constants.dart';
@ -7,10 +6,10 @@ import 'package:managerapi/api.dart';
import 'dropDown_configuration.dart';
showChangeInfo (String text, DeviceDTO inputDevice, Function onGetResult, int maxLines, BuildContext mainContext, dynamic appContext) {
showChangeInfo (String text, DeviceDTO inputDevice, Function onGetResult, int maxLines, BuildContext mainContext, dynamic appContext) async {
Size size = MediaQuery.of(mainContext).size;
showDialog(
var result = await showDialog(
builder: (BuildContext context) => AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(20.0))

View File

@ -1,24 +1,21 @@
import 'dart:io';
import 'package:manager_app/Components/message_notification.dart';
import 'package:manager_app/Components/resource_tab.dart';
import 'package:flutter/material.dart';
import 'package:manager_app/Components/message_notification.dart';
import 'package:manager_app/Components/rounded_button.dart';
import 'package:manager_app/Components/string_input_container.dart';
import 'package:manager_app/Models/managerContext.dart';
import 'package:manager_app/app_context.dart';
import 'package:manager_app/constants.dart';
import 'package:managerapi/api.dart';
import 'package:http/http.dart' as http;
void showNewResource(AppContext appContext, BuildContext context) {
dynamic showNewResource(AppContext appContext, BuildContext context) async {
ResourceDetailDTO resourceDetailDTO = new ResourceDetailDTO();
Size size = MediaQuery.of(context).size;
var fileName;
File fileToSend;
showDialog(
var result = await showDialog(
builder: (BuildContext context) => AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(20.0))
@ -86,7 +83,17 @@ void showNewResource(AppContext appContext, BuildContext context) {
color: kPrimaryColor,
textColor: kWhite,
press: () {
create(resourceDetailDTO, fileToSend, appContext, context);
if (resourceDetailDTO.label != null) {
if (fileToSend != null) {
Navigator.pop(context, [resourceDetailDTO, fileToSend]);
} else {
showNotification(Colors.orange, kWhite, 'Aucun fichier n\'a été chargé', context);
}
} else {
showNotification(Colors.orange, kWhite, 'Veuillez donner un nom à la ressource', context);
}
//Navigator.of(context).pop();
//create(resourceDetailDTO, fileToSend, appContext, context);
},
fontSize: 20,
),
@ -97,71 +104,6 @@ void showNewResource(AppContext appContext, BuildContext context) {
],
), context: context
);
return result;
}
void create(ResourceDetailDTO resourceDetailDTO, File file, AppContext appContext, context) async {
if (resourceDetailDTO.label != null) {
switch(resourceDetailDTO.type) {
case ResourceType.image:
case ResourceType.video:
if (file != null) {
var request = http.MultipartRequest('POST', Uri.parse(appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/upload"));
request.files.add(
await http.MultipartFile(
'picture',
file.readAsBytes().asStream(),
file.lengthSync(),
filename: file.path.toString().split("/").last
)
);
ManagerAppContext managerAppContext = appContext.getContext();
request.headers["authorization"]="Bearer ${managerAppContext.token.accessToken}";
request.fields['label'] = resourceDetailDTO.label;
request.fields['type'] = ResourceType.image.toString();
var res = await request.send();
if (res.statusCode == 200) {
// To refresh only (UGLY COOOOODE)
ManagerAppContext managerAppContext = appContext.getContext();
appContext.setContext(managerAppContext);
showNotification(Colors.green, kWhite, 'La ressource a été créée avec succès', context);
} else {
showNotification(kPrimaryColor, kWhite, 'Une erreur est survenue lors de la création de la ressource', context);
}
} else {
showNotification(Colors.orange, kWhite, 'Aucun fichier n\'a été chargé', context);
}
Navigator.of(context).pop();
break;
case ResourceType.imageUrl:
case ResourceType.videoUrl:
if (resourceDetailDTO.data != null) {
// test if Correct url
bool _validURL = Uri.parse(resourceDetailDTO.data).isAbsolute;
if(_validURL) {
Navigator.of(context).pop();
ResourceDetailDTO newResource = await appContext.getContext().clientAPI.resourceApi.resourceCreate(resourceDetailDTO);
// To refresh only (UGLY COOOOODE)
ManagerAppContext managerAppContext = appContext.getContext();
appContext.setContext(managerAppContext);
showNotification(Colors.green, kWhite, 'La ressource a été créée avec succès', context);
} else {
showNotification(Colors.orange, kWhite, 'L\'url est invalide', context);
}
} else {
showNotification(Colors.orange, kWhite, 'Veuillez remplir le champ URL', context);
}
break;
}
} else {
showNotification(Colors.orange, kWhite, 'Veuillez donner un nom à la ressource', context);
}
}

View File

@ -12,11 +12,13 @@ class ResourceBodyGrid extends StatefulWidget {
final List<ResourceDTO> resources; //return ResourceDTO
final Function onSelect;
final bool isImage;
final bool isAddButton;
const ResourceBodyGrid({
Key key,
this.resources,
this.onSelect,
this.isImage,
this.isAddButton,
}) : super(key: key);
@override
@ -78,10 +80,13 @@ class _ResourceBodyGridState extends State<ResourceBodyGrid> {
},
),
),
if (widget.isAddButton)
InkWell(
onTap: () {
widget.onSelect(ResourceDTO(id: null));
},
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
height: size.height *0.08,
width: size.height *0.08,
@ -106,6 +111,7 @@ class _ResourceBodyGridState extends State<ResourceBodyGrid> {
}),
),
),
),
)
],
),

View File

@ -1,8 +1,10 @@
import 'package:auto_size_text/auto_size_text.dart';
import 'dart:convert';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:manager_app/Components/fetch_resource_icon.dart';
import 'package:manager_app/Components/loading.dart';
import 'package:manager_app/Components/string_input_container.dart';
import 'package:manager_app/Components/message_notification.dart';
import 'package:manager_app/Models/managerContext.dart';
import 'package:manager_app/Screens/Resources/new_resource_popup.dart';
import 'package:manager_app/Screens/Resources/resource_body_grid.dart';
import 'package:manager_app/Screens/Resources/show_resource_popup.dart';
@ -10,14 +12,17 @@ import 'package:manager_app/app_context.dart';
import 'package:manager_app/constants.dart';
import 'package:managerapi/api.dart';
import 'package:provider/provider.dart';
import 'package:http/http.dart' as http;
class ResourcesScreen extends StatefulWidget {
final Function onGetResult; //return ResourceDTO
final bool isImage;
final bool isAddButton;
const ResourcesScreen({
Key key,
this.isImage = false,
this.onGetResult,
this.isAddButton = true,
}) : super(key: key);
@override
@ -26,6 +31,7 @@ class ResourcesScreen extends StatefulWidget {
class _ResourcesScreenState extends State<ResourcesScreen> {
String filter;
bool isLoading;
@override
Widget build(BuildContext context) {
@ -38,22 +44,23 @@ class _ResourcesScreenState extends State<ResourcesScreen> {
if (snapshot.connectionState == ConnectionState.done) {
var tempOutput = new List<ResourceDTO>.from(snapshot.data);
// tempOutput.add(ResourceDTO(id: null));
return ResourceBodyGrid(resources: tempOutput, isImage: widget.isImage, onSelect: (value) {
return ResourceBodyGrid(resources: tempOutput, isImage: widget.isImage, isAddButton: widget.isAddButton, onSelect: (value) async {
if (widget.onGetResult == null) {
// Main screen
if (value.id == null) {
showNewResource(appContext, context);
var result = await showNewResource(appContext, context);
if (result != null)
{
var newResource = await create(result[0], result[1], appContext, context);
setState(() {}); // For refresh
}
} else {
showResource(value, appContext, context, size);
}
} else {
if (value.id == null) {
showNewResource(appContext, context);
} else {
// Result for select modal
widget.onGetResult(value);
}
}
},);//bodyGrid(tempOutput, size, appContext);
} else if (snapshot.connectionState == ConnectionState.none) {
return Text("No data");
@ -77,3 +84,61 @@ Future<List<ResourceDTO>> getResources(Function onGetResult, bool isImage, dynam
}
return resources;
}
Future<ResourceDTO> create(ResourceDetailDTO resourceDetailDTO, File file, AppContext appContext, context) async {
switch(resourceDetailDTO.type) {
case ResourceType.image:
case ResourceType.video:
var request = http.MultipartRequest('POST', Uri.parse(appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/upload"));
request.files.add(
await http.MultipartFile(
'picture',
file.readAsBytes().asStream(),
file.lengthSync(),
filename: file.path.toString().split("/").last
)
);
ManagerAppContext managerAppContext = appContext.getContext();
request.headers["authorization"]="Bearer ${managerAppContext.token.accessToken}";
request.fields['label'] = resourceDetailDTO.label;
request.fields['type'] = ResourceType.image.toString();
var res = await request.send();
final respStr = await res.stream.bytesToString();
if (res.statusCode == 200) {
var result = ResourceDTO.fromJson(jsonDecode(respStr));
showNotification(Colors.green, kWhite, 'La ressource a été créée avec succès', context);
return result;
} else {
showNotification(kPrimaryColor, kWhite, 'Une erreur est survenue lors de la création de la ressource', context);
}
break;
case ResourceType.imageUrl:
case ResourceType.videoUrl:
if (resourceDetailDTO.data != null) {
// test if Correct url
bool _validURL = Uri.parse(resourceDetailDTO.data).isAbsolute;
if(_validURL) {
Navigator.of(context).pop();
ResourceDTO newResource = await appContext.getContext().clientAPI.resourceApi.resourceCreate(resourceDetailDTO);
// To refresh only (UGLY COOOOODE)
/*ManagerAppContext managerAppContext = appContext.getContext();
appContext.setContext(managerAppContext);*/
showNotification(Colors.green, kWhite, 'La ressource a été créée avec succès', context);
return newResource;
} else {
showNotification(Colors.orange, kWhite, 'L\'url est invalide', context);
}
} else {
showNotification(Colors.orange, kWhite, 'Veuillez remplir le champ URL', context);
}
break;
}
}

View File

@ -5,10 +5,10 @@ import 'package:manager_app/Screens/Resources/resources_screen.dart';
import 'package:manager_app/constants.dart';
import 'package:managerapi/api.dart';
showSelectResourceModal (String text, Function onGetResult, int maxLines, bool onlyImage, BuildContext mainContext) { /*Function onSelect,*/
dynamic showSelectResourceModal (String text, int maxLines, bool onlyImage, BuildContext mainContext) async { /*Function onSelect,*/
Size size = MediaQuery.of(mainContext).size;
showDialog(
var result = await showDialog(
builder: (BuildContext context) => AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(20.0))
@ -21,10 +21,13 @@ showSelectResourceModal (String text, Function onGetResult, int maxLines, bool o
width: size.width * 0.7,
height: size.height * 0.75,
child: ResourcesScreen(
isAddButton: false,
onGetResult: (ResourceDTO resource) {
print("SELECT RESOURCE");
print(resource);
if (resource != null) {
onGetResult(resource);
Navigator.of(mainContext).pop();
var result = resource;
Navigator.pop(context, result);
}
},
isImage: onlyImage,
@ -55,6 +58,7 @@ showSelectResourceModal (String text, Function onGetResult, int maxLines, bool o
],
), context: mainContext
);
return result;
}
showValues(List<TranslationDTO> newValues) {

View File

@ -1,3 +1,5 @@
import 'dart:io';
import 'package:manager_app/Models/managerContext.dart';
import 'package:manager_app/Screens/Main/main_screen.dart';
import 'package:flutter/material.dart';
@ -5,10 +7,18 @@ import 'package:provider/provider.dart';
import 'Screens/login_screen.dart';
import 'app_context.dart';
import 'constants.dart';
import 'package:window_size/window_size.dart';
void main() {
Future<void> main() async {
String initialRoute;
WidgetsFlutterBinding.ensureInitialized();
if (Platform.isWindows) {
setWindowTitle("My Desktop App");
setWindowMinSize(Size(1100, 900));
setWindowMaxSize(Size(3840, 2160));
}
initialRoute = '/welcome';
final MyApp myApp = MyApp(

View File

@ -7,9 +7,13 @@
#include "generated_plugin_registrant.h"
#include <dart_vlc/dart_vlc_plugin.h>
#include <window_size/window_size_plugin.h>
void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) dart_vlc_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "DartVlcPlugin");
dart_vlc_plugin_register_with_registrar(dart_vlc_registrar);
g_autoptr(FlPluginRegistrar) window_size_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "WindowSizePlugin");
window_size_plugin_register_with_registrar(window_size_registrar);
}

View File

@ -4,6 +4,7 @@
list(APPEND FLUTTER_PLUGIN_LIST
dart_vlc
window_size
)
set(PLUGIN_BUNDLED_LIBRARIES)

View File

@ -8,7 +8,9 @@ import FlutterMacOS
import Foundation
import path_provider_macos
import window_size
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
WindowSizePlugin.register(with: registry.registrar(forPlugin: "WindowSizePlugin"))
}

View File

@ -385,6 +385,15 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.5"
window_size:
dependency: "direct main"
description:
path: "plugins/window_size"
ref: "927f8cbc09b35d85245c095f2db8df9b186f6618"
resolved-ref: "927f8cbc09b35d85245c095f2db8df9b186f6618"
url: "git://github.com/google/flutter-desktop-embedding.git"
source: git
version: "0.1.0"
xdg_directories:
dependency: transitive
description:

View File

@ -37,6 +37,11 @@ dependencies:
dart_vlc: ^0.0.6
video_player: ^2.1.1
drag_and_drop_lists: ^0.3.2
window_size:
git:
url: git://github.com/google/flutter-desktop-embedding.git
path: plugins/window_size
ref: 927f8cbc09b35d85245c095f2db8df9b186f6618
managerapi:
path: manager_api

View File

@ -7,8 +7,11 @@
#include "generated_plugin_registrant.h"
#include <dart_vlc/dart_vlc_plugin.h>
#include <window_size/window_size_plugin.h>
void RegisterPlugins(flutter::PluginRegistry* registry) {
DartVlcPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("DartVlcPlugin"));
WindowSizePluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("WindowSizePlugin"));
}

View File

@ -4,6 +4,7 @@
list(APPEND FLUTTER_PLUGIN_LIST
dart_vlc
window_size
)
set(PLUGIN_BUNDLED_LIBRARIES)