Upload url image + url video WIP
This commit is contained in:
parent
fa378695f8
commit
a116508dd5
@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:managerapi/api.dart';
|
import 'package:managerapi/api.dart';
|
||||||
|
|
||||||
IconData getResourceIcon(elementType) {
|
IconData getResourceIcon(elementType) {
|
||||||
print(elementType);
|
|
||||||
switch(elementType) {
|
switch(elementType) {
|
||||||
case ResourceType.image:
|
case ResourceType.image:
|
||||||
return Icons.image;
|
return Icons.image;
|
||||||
|
|||||||
@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:managerapi/api.dart';
|
import 'package:managerapi/api.dart';
|
||||||
|
|
||||||
IconData getSectionIcon(elementType) {
|
IconData getSectionIcon(elementType) {
|
||||||
print(elementType);
|
|
||||||
switch(elementType) {
|
switch(elementType) {
|
||||||
case SectionType.map:
|
case SectionType.map:
|
||||||
return Icons.location_on;
|
return Icons.location_on;
|
||||||
|
|||||||
@ -77,7 +77,7 @@ showValues(List<TranslationDTO> newValues) {
|
|||||||
List<Widget> valuesToShow = new List<Widget>();
|
List<Widget> valuesToShow = new List<Widget>();
|
||||||
newValues.forEach((newValue) {
|
newValues.forEach((newValue) {
|
||||||
valuesToShow.add(
|
valuesToShow.add(
|
||||||
new StringContainer(
|
new StringInputContainer(
|
||||||
color: Colors.lightBlue,
|
color: Colors.lightBlue,
|
||||||
label: newValue.language,
|
label: newValue.language,
|
||||||
initialValue: newValue.value,
|
initialValue: newValue.value,
|
||||||
|
|||||||
138
lib/Components/resource_tab.dart
Normal file
138
lib/Components/resource_tab.dart
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:manager_app/Components/rounded_input_field.dart';
|
||||||
|
import 'package:manager_app/Components/upload_online_resources_container.dart';
|
||||||
|
import 'file:///C:/Users/Thomas%20Fransolet/Documents/Documents/Perso/MuseeDeLaFraise/manager-app/lib/Components/upload_image_container.dart';
|
||||||
|
import 'package:manager_app/constants.dart';
|
||||||
|
import 'package:managerapi/api.dart';
|
||||||
|
class ResourceTab extends StatefulWidget {
|
||||||
|
final ResourceDetailDTO resourceDetailDTO;
|
||||||
|
const ResourceTab({
|
||||||
|
Key key,
|
||||||
|
this.resourceDetailDTO,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_ResourceTabState createState() => _ResourceTabState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ResourceTabState extends State<ResourceTab> with SingleTickerProviderStateMixin {
|
||||||
|
TabController _tabController;
|
||||||
|
List<Tab> tabsToShow = new List<Tab>();
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
tabsToShow.add(new Tab(text: "Image local"));
|
||||||
|
tabsToShow.add(new Tab(text: "Image en ligne"));
|
||||||
|
tabsToShow.add(new Tab(text: "Vidéo en ligne"));
|
||||||
|
|
||||||
|
_tabController = new TabController(length: 3, vsync: this);
|
||||||
|
_tabController.addListener(_handleTabSelection);
|
||||||
|
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
body: Container(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
TabBar(
|
||||||
|
unselectedLabelColor: Colors.black,
|
||||||
|
labelColor: kPrimaryColor,
|
||||||
|
tabs: tabsToShow,
|
||||||
|
controller: _tabController,
|
||||||
|
indicatorSize: TabBarIndicatorSize.tab,
|
||||||
|
indicatorColor: kPrimaryColor,
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: TabBarView(
|
||||||
|
children: getContent(widget.resourceDetailDTO),
|
||||||
|
controller: _tabController,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _handleTabSelection() {
|
||||||
|
print("_handleTabSelection");
|
||||||
|
print(_tabController.index);
|
||||||
|
switch(_tabController.index) {
|
||||||
|
case 0:
|
||||||
|
setState(() {
|
||||||
|
widget.resourceDetailDTO.data = null;
|
||||||
|
widget.resourceDetailDTO.type = ResourceType.image;
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
setState(() {
|
||||||
|
widget.resourceDetailDTO.data = null;
|
||||||
|
widget.resourceDetailDTO.type = ResourceType.imageUrl;
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
setState(() {
|
||||||
|
widget.resourceDetailDTO.data = null;
|
||||||
|
widget.resourceDetailDTO.type = ResourceType.videoUrl;
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getContent(ResourceDetailDTO resourceDetailDTO) {
|
||||||
|
List<Widget> tabsToShow = new List<Widget>();
|
||||||
|
|
||||||
|
print("getContent");
|
||||||
|
print(resourceDetailDTO);
|
||||||
|
|
||||||
|
// Local Image
|
||||||
|
tabsToShow.add(
|
||||||
|
new Padding(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 8, vertical: 16),
|
||||||
|
child: UploadImageContainer(
|
||||||
|
onChanged: (File file) {
|
||||||
|
print("ONCHANGED image");
|
||||||
|
print(file.path);
|
||||||
|
//fileToSend = file;
|
||||||
|
resourceDetailDTO.type = ResourceType.image;
|
||||||
|
}
|
||||||
|
),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Online Image
|
||||||
|
tabsToShow.add(
|
||||||
|
new Padding(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 8, vertical: 16),
|
||||||
|
child: UploadOnlineResourceContainer(
|
||||||
|
resourceDetailDTO: resourceDetailDTO,
|
||||||
|
onChanged: (ResourceDetailDTO value) {
|
||||||
|
print("ONcHanged UploadOnlineResourceContainer parent");
|
||||||
|
resourceDetailDTO = value;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Online Video
|
||||||
|
tabsToShow.add(
|
||||||
|
new Padding(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 8, vertical: 16),
|
||||||
|
child: UploadOnlineResourceContainer(
|
||||||
|
resourceDetailDTO: resourceDetailDTO,
|
||||||
|
onChanged: (ResourceDetailDTO value) {
|
||||||
|
print("ONcHanged UploadOnlineResourceContainer parent");
|
||||||
|
resourceDetailDTO = value;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return tabsToShow;
|
||||||
|
}
|
||||||
@ -2,12 +2,12 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:manager_app/Components/rounded_input_field.dart';
|
import 'package:manager_app/Components/rounded_input_field.dart';
|
||||||
import 'package:manager_app/constants.dart';
|
import 'package:manager_app/constants.dart';
|
||||||
|
|
||||||
class StringContainer extends StatelessWidget {
|
class StringInputContainer extends StatelessWidget {
|
||||||
final Color color;
|
final Color color;
|
||||||
final String label;
|
final String label;
|
||||||
final String initialValue;
|
final String initialValue;
|
||||||
final ValueChanged<String> onChanged;
|
final ValueChanged<String> onChanged;
|
||||||
const StringContainer({
|
const StringInputContainer({
|
||||||
Key key,
|
Key key,
|
||||||
this.color = kSecond,
|
this.color = kSecond,
|
||||||
this.label,
|
this.label,
|
||||||
|
|||||||
@ -31,60 +31,11 @@ class _UploadImageContainerState extends State<UploadImageContainer> with Single
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
Size size = MediaQuery.of(context).size;
|
||||||
return Container(
|
return Container(
|
||||||
width: 500,
|
width: size.width *0.5,
|
||||||
child: Column(
|
height: size.height *0.5,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
child: displayElement(),
|
||||||
children: [
|
|
||||||
if (fileToShow == null) InkWell(
|
|
||||||
onTap: () async {
|
|
||||||
filePicker();
|
|
||||||
},
|
|
||||||
child: Container(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: kPrimaryColor,
|
|
||||||
borderRadius: BorderRadius.circular(15)
|
|
||||||
),
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 25.0, right: 25.0, top: 15.0, bottom: 15.0),
|
|
||||||
child: Text(
|
|
||||||
"Ajouter un fichier",
|
|
||||||
style: new TextStyle(color: kWhite),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (fileToShow != null)
|
|
||||||
Container(
|
|
||||||
margin: EdgeInsets.all(8.0),
|
|
||||||
child: Card(
|
|
||||||
color: kBackgroundColor,
|
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(8.0))),
|
|
||||||
child: InkWell(
|
|
||||||
onTap: () async {
|
|
||||||
filePicker();
|
|
||||||
},
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
||||||
children: <Widget>[
|
|
||||||
ClipRRect(
|
|
||||||
borderRadius: BorderRadius.only(
|
|
||||||
topLeft: Radius.circular(8.0),
|
|
||||||
topRight: Radius.circular(8.0),
|
|
||||||
),
|
|
||||||
child: showFile()
|
|
||||||
),
|
|
||||||
ListTile(
|
|
||||||
title: Text(getFileName(filePath)),
|
|
||||||
subtitle: Text(filePath),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,8 +47,8 @@ class _UploadImageContainerState extends State<UploadImageContainer> with Single
|
|||||||
final file = OpenFilePicker()
|
final file = OpenFilePicker()
|
||||||
..filterSpecification = {
|
..filterSpecification = {
|
||||||
'Images (*.jpg; *.png)': '*.jpg;*.png',
|
'Images (*.jpg; *.png)': '*.jpg;*.png',
|
||||||
'Video (*.mp4)': '*.mp4',
|
//'Video (*.mp4)': '*.mp4',
|
||||||
'All Files': '*.*'
|
//'All Files': '*.*'
|
||||||
}
|
}
|
||||||
..defaultFilterIndex = 0
|
..defaultFilterIndex = 0
|
||||||
..title = 'Sélectionner un fichier';
|
..title = 'Sélectionner un fichier';
|
||||||
@ -148,6 +99,58 @@ class _UploadImageContainerState extends State<UploadImageContainer> with Single
|
|||||||
loadFile(File fileToShow) async {
|
loadFile(File fileToShow) async {
|
||||||
return await Media.file(fileToShow);
|
return await Media.file(fileToShow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
displayElement() {
|
||||||
|
if (fileToShow == null) return Center(
|
||||||
|
child: InkWell(
|
||||||
|
onTap: () async {
|
||||||
|
filePicker();
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: kPrimaryColor,
|
||||||
|
borderRadius: BorderRadius.circular(15)
|
||||||
|
),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 25.0, right: 25.0, top: 15.0, bottom: 15.0),
|
||||||
|
child: Text(
|
||||||
|
"Ajouter un fichier",
|
||||||
|
style: new TextStyle(color: kWhite),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
if (fileToShow != null)
|
||||||
|
return Container(
|
||||||
|
margin: EdgeInsets.all(8.0),
|
||||||
|
child: Card(
|
||||||
|
color: kBackgroundColor,
|
||||||
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(8.0))),
|
||||||
|
child: InkWell(
|
||||||
|
onTap: () async {
|
||||||
|
filePicker();
|
||||||
|
},
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: <Widget>[
|
||||||
|
ClipRRect(
|
||||||
|
borderRadius: BorderRadius.only(
|
||||||
|
topLeft: Radius.circular(8.0),
|
||||||
|
topRight: Radius.circular(8.0),
|
||||||
|
),
|
||||||
|
child: showFile()
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
|
title: Text(getFileName(filePath)),
|
||||||
|
subtitle: Text(filePath),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Upload(File imageFile) async {
|
Upload(File imageFile) async {
|
||||||
116
lib/Components/upload_online_resources_container.dart
Normal file
116
lib/Components/upload_online_resources_container.dart
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
import 'package:dart_vlc/dart_vlc.dart';
|
||||||
|
import 'package:manager_app/Components/rounded_input_field.dart';
|
||||||
|
import 'package:manager_app/Components/string_input_container.dart';
|
||||||
|
import 'package:manager_app/Components/vlc_viewer.dart';
|
||||||
|
import 'package:manager_app/constants.dart';
|
||||||
|
import 'package:managerapi/api.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class UploadOnlineResourceContainer extends StatefulWidget {
|
||||||
|
final ResourceDetailDTO resourceDetailDTO;
|
||||||
|
final ValueChanged<ResourceDetailDTO> onChanged;
|
||||||
|
const UploadOnlineResourceContainer({
|
||||||
|
Key key,
|
||||||
|
this.resourceDetailDTO,
|
||||||
|
this.onChanged,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_UploadOnlineResourceContainerState createState() => _UploadOnlineResourceContainerState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _UploadOnlineResourceContainerState extends State<UploadOnlineResourceContainer> with SingleTickerProviderStateMixin {
|
||||||
|
String urlResourceToShow;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
Size size = MediaQuery.of(context).size;
|
||||||
|
print(size.width);
|
||||||
|
return displayElement(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
showFile() {
|
||||||
|
if (widget.resourceDetailDTO.type == ResourceType.videoUrl || widget.resourceDetailDTO.type == ResourceType.video) {
|
||||||
|
return FutureBuilder(
|
||||||
|
future: loadFile(urlResourceToShow),
|
||||||
|
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
||||||
|
if (snapshot.connectionState == ConnectionState.done) {
|
||||||
|
return Container(
|
||||||
|
height: 300,
|
||||||
|
child: DartVLC(file: snapshot.data)
|
||||||
|
);
|
||||||
|
} else if (snapshot.connectionState == ConnectionState.none) {
|
||||||
|
return Text("No data");
|
||||||
|
} else {
|
||||||
|
return Center(child: Container(height: 200, child: Text('LOADING TODO FRAISE')));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
/*await Media.file(widget.file)*/
|
||||||
|
} else {
|
||||||
|
return Image.network(
|
||||||
|
urlResourceToShow,
|
||||||
|
height: 200,
|
||||||
|
fit:BoxFit.scaleDown
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
loadFile(String urlResourceToShow) async {
|
||||||
|
return await Media.network(urlResourceToShow);
|
||||||
|
}
|
||||||
|
|
||||||
|
displayElement(Size size) {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
Center(
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Align(
|
||||||
|
alignment: AlignmentDirectional.center,
|
||||||
|
child: Text("URL:", style: TextStyle(fontSize: 25, fontWeight: FontWeight.w300))
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Container(
|
||||||
|
width: size.width *0.35, // TODO GET SIZE
|
||||||
|
child: RoundedInputField(
|
||||||
|
hintText: widget.resourceDetailDTO.type == ResourceType.imageUrl ? "Url de l'image" : "Url de la vidéo",
|
||||||
|
icon: widget.resourceDetailDTO.type == ResourceType.imageUrl ? Icons.image : Icons.ondemand_video, // TODO: TBD
|
||||||
|
onChanged: (String text) {
|
||||||
|
print("onchanged url");
|
||||||
|
widget.resourceDetailDTO.data = text;
|
||||||
|
},
|
||||||
|
initialValue: ""
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
InkWell(
|
||||||
|
onTap: () {
|
||||||
|
print("refresh preview");
|
||||||
|
setState(() {
|
||||||
|
urlResourceToShow = widget.resourceDetailDTO.data;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
child: Center(
|
||||||
|
child: Icon(
|
||||||
|
Icons.cloud_download_outlined,
|
||||||
|
color: kPrimaryColor,
|
||||||
|
size: 35,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if(widget.resourceDetailDTO.data != null) showFile()
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -122,7 +122,7 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
|
|||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
StringContainer(
|
StringInputContainer(
|
||||||
label: "Nom :",
|
label: "Nom :",
|
||||||
initialValue: sectionDTO.label,
|
initialValue: sectionDTO.label,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
@ -139,7 +139,7 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
|
|||||||
sectionDTO.type = SectionType.fromJson(tempOutput[0]);
|
sectionDTO.type = SectionType.fromJson(tempOutput[0]);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
StringContainer(
|
StringInputContainer(
|
||||||
label: "Image :",
|
label: "Image :",
|
||||||
initialValue: sectionDTO.imageId,
|
initialValue: sectionDTO.imageId,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
|
|||||||
@ -114,7 +114,7 @@ class _ConfigurationDetailScreenState extends State<ConfigurationDetailScreen> {
|
|||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
StringContainer(
|
StringInputContainer(
|
||||||
label: "Nom :",
|
label: "Nom :",
|
||||||
initialValue: configurationDTO.label,
|
initialValue: configurationDTO.label,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
|
|||||||
@ -20,7 +20,7 @@ void showNewConfiguration(AppContext appContext, BuildContext context) {
|
|||||||
Text("Nouvelle configuration", style: new TextStyle(fontSize: 25, fontWeight: FontWeight.w400)),
|
Text("Nouvelle configuration", style: new TextStyle(fontSize: 25, fontWeight: FontWeight.w400)),
|
||||||
Column(
|
Column(
|
||||||
children: [
|
children: [
|
||||||
StringContainer(
|
StringInputContainer(
|
||||||
label: "Nom :",
|
label: "Nom :",
|
||||||
initialValue: configurationDTO.label,
|
initialValue: configurationDTO.label,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
|
|||||||
@ -23,7 +23,7 @@ void showNewSection(ConfigurationDTO configurationDTO, AppContext appContext, Bu
|
|||||||
Text("Nouvelle section", style: new TextStyle(fontSize: 25, fontWeight: FontWeight.w400)),
|
Text("Nouvelle section", style: new TextStyle(fontSize: 25, fontWeight: FontWeight.w400)),
|
||||||
Column(
|
Column(
|
||||||
children: [
|
children: [
|
||||||
StringContainer(
|
StringInputContainer(
|
||||||
label: "Nom :",
|
label: "Nom :",
|
||||||
initialValue: sectionDTO.label,
|
initialValue: sectionDTO.label,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:manager_app/Screens/Resources/upload_image.dart';
|
import 'package:manager_app/Components/resource_tab.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:manager_app/Components/message_notification.dart';
|
import 'package:manager_app/Components/message_notification.dart';
|
||||||
import 'package:manager_app/Components/rounded_button.dart';
|
import 'package:manager_app/Components/rounded_button.dart';
|
||||||
@ -14,6 +14,7 @@ import 'package:http/http.dart' as http;
|
|||||||
|
|
||||||
void showNewResource(AppContext appContext, BuildContext context) {
|
void showNewResource(AppContext appContext, BuildContext context) {
|
||||||
ResourceDetailDTO resourceDetailDTO = new ResourceDetailDTO();
|
ResourceDetailDTO resourceDetailDTO = new ResourceDetailDTO();
|
||||||
|
Size size = MediaQuery.of(context).size;
|
||||||
var fileName;
|
var fileName;
|
||||||
File fileToSend;
|
File fileToSend;
|
||||||
showDialog(
|
showDialog(
|
||||||
@ -22,14 +23,14 @@ void showNewResource(AppContext appContext, BuildContext context) {
|
|||||||
borderRadius: BorderRadius.all(Radius.circular(20.0))
|
borderRadius: BorderRadius.all(Radius.circular(20.0))
|
||||||
),
|
),
|
||||||
content: Container(
|
content: Container(
|
||||||
width: 400,
|
width: size.width *0.5,
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Text("Nouvelle ressource", style: new TextStyle(fontSize: 25, fontWeight: FontWeight.w400)),
|
Text("Nouvelle ressource", style: new TextStyle(fontSize: 25, fontWeight: FontWeight.w400)),
|
||||||
Column(
|
Column(
|
||||||
children: [
|
children: [
|
||||||
StringContainer(
|
StringInputContainer(
|
||||||
label: "Nom :",
|
label: "Nom :",
|
||||||
initialValue: resourceDetailDTO.label,
|
initialValue: resourceDetailDTO.label,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
@ -39,13 +40,12 @@ void showNewResource(AppContext appContext, BuildContext context) {
|
|||||||
if (fileName != null) new Text(fileName),
|
if (fileName != null) new Text(fileName),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
UploadImageContainer(
|
Container(
|
||||||
onChanged: (File file) {
|
width: size.width *0.5,
|
||||||
print("ONCHANGED image");
|
height: size.height *0.5,
|
||||||
print(file.path);
|
child: ResourceTab(
|
||||||
fileToSend = file;
|
resourceDetailDTO: resourceDetailDTO,
|
||||||
resourceDetailDTO.type = ResourceType.image;
|
)
|
||||||
}
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
@ -93,7 +93,7 @@ class _ResourcesScreenState extends State<ResourcesScreen> {
|
|||||||
height: size.height *0.08,
|
height: size.height *0.08,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Image.network(
|
child: Image.network(
|
||||||
appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ resource.id,
|
resource.type == ResourceType.image ? appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ resource.id : "https://miro.medium.com/max/1920/1*8wFh-pEuwyAGa1IaKb-lEw.png",
|
||||||
fit:BoxFit.fill
|
fit:BoxFit.fill
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -34,7 +34,7 @@ void showResource(ResourceDTO resourceDTO,AppContext appContext, BuildContext co
|
|||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(10.0),
|
padding: const EdgeInsets.all(10.0),
|
||||||
child: Image.network(
|
child: Image.network(
|
||||||
appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ resourceDTO.id,
|
resourceDTO.type == ResourceType.image ? appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ resourceDTO.id : "https://miro.medium.com/max/1920/1*8wFh-pEuwyAGa1IaKb-lEw.png",
|
||||||
fit:BoxFit.scaleDown
|
fit:BoxFit.scaleDown
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user