Add Article management !
This commit is contained in:
parent
aa59561dc1
commit
7195ebb64f
@ -0,0 +1,208 @@
|
|||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:manager_app/Components/check_input_container.dart';
|
||||||
|
import 'package:manager_app/Components/multi_string_input_container.dart';
|
||||||
|
import 'package:manager_app/Screens/Configurations/Section/SubSection/Slider/listView_card_image.dart';
|
||||||
|
import 'package:manager_app/Screens/Configurations/Section/SubSection/Slider/new_update_image_slider.dart';
|
||||||
|
import 'package:manager_app/app_context.dart';
|
||||||
|
import 'package:manager_app/constants.dart';
|
||||||
|
import 'package:managerapi/api.dart';
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
|
||||||
|
class ArticleConfig extends StatefulWidget {
|
||||||
|
final String color;
|
||||||
|
final String label;
|
||||||
|
final String initialValue;
|
||||||
|
final ValueChanged<String> onChanged;
|
||||||
|
const ArticleConfig({
|
||||||
|
Key key,
|
||||||
|
this.color,
|
||||||
|
this.label,
|
||||||
|
this.initialValue,
|
||||||
|
this.onChanged,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_ArticleConfigState createState() => _ArticleConfigState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ArticleConfigState extends State<ArticleConfig> {
|
||||||
|
ArticleDTO articleDTO;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
articleDTO = ArticleDTO.fromJson(json.decode(widget.initialValue));
|
||||||
|
List<ImageDTO> test = new List<ImageDTO>.from(articleDTO.images);
|
||||||
|
|
||||||
|
articleDTO.images = test;
|
||||||
|
articleDTO.images.sort((a, b) => a.order.compareTo(b.order));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final appContext = Provider.of<AppContext>(context);
|
||||||
|
Size size = MediaQuery.of(context).size;
|
||||||
|
|
||||||
|
void _onReorder(int oldIndex, int newIndex) {
|
||||||
|
setState(
|
||||||
|
() {
|
||||||
|
if (newIndex > oldIndex) {
|
||||||
|
newIndex -= 1;
|
||||||
|
}
|
||||||
|
final ImageDTO item = articleDTO.images.removeAt(oldIndex);
|
||||||
|
articleDTO.images.insert(newIndex, item);
|
||||||
|
|
||||||
|
var i = 0;
|
||||||
|
articleDTO.images.forEach((image) {
|
||||||
|
image.order = i;
|
||||||
|
i++;
|
||||||
|
});
|
||||||
|
|
||||||
|
widget.onChanged(jsonEncode(articleDTO).toString());
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
SingleChildScrollView(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
height: size.height * 0.1,
|
||||||
|
//width: size.width * 0.5,//,
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
|
children: [
|
||||||
|
// Bad
|
||||||
|
MultiStringContainer(
|
||||||
|
label: "Contenu affiché:",
|
||||||
|
modalLabel: "Contenu",
|
||||||
|
color: kPrimaryColor,
|
||||||
|
initialValue: articleDTO != null ? articleDTO.content : [],
|
||||||
|
onGetResult: (value) {
|
||||||
|
setState(() {
|
||||||
|
if (articleDTO.content != value) {
|
||||||
|
articleDTO.content = value;
|
||||||
|
//save(true, articleDTO, appContext);
|
||||||
|
widget.onChanged(jsonEncode(articleDTO).toString());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
maxLines: 1,
|
||||||
|
),
|
||||||
|
CheckInputContainer(
|
||||||
|
label: "Contenu au-dessus :",
|
||||||
|
isChecked: articleDTO.isContentTop,
|
||||||
|
onChanged: (value) {
|
||||||
|
setState(() {
|
||||||
|
print(value);
|
||||||
|
articleDTO.isContentTop = value;
|
||||||
|
widget.onChanged(jsonEncode(articleDTO).toString());
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(25),
|
||||||
|
border: Border.all(width: 1.5, color: kSecond)
|
||||||
|
),
|
||||||
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 40, left: 10, right: 10, bottom: 10),
|
||||||
|
child: Container(
|
||||||
|
height: 250,
|
||||||
|
width: size.height * 0.95,
|
||||||
|
child: ReorderableListView(
|
||||||
|
onReorder: _onReorder,
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 20.0),
|
||||||
|
children: List.generate(
|
||||||
|
articleDTO.images.length,
|
||||||
|
(index) {
|
||||||
|
return ListViewCardImage(
|
||||||
|
articleDTO.images,
|
||||||
|
index,
|
||||||
|
Key('$index'),
|
||||||
|
appContext,
|
||||||
|
(images) {
|
||||||
|
setState(() {
|
||||||
|
List<ImageDTO> test = new List<ImageDTO>.from(images);
|
||||||
|
articleDTO.images = test;
|
||||||
|
List<ImageDTO> testToSend = new List<ImageDTO>.from(images);
|
||||||
|
testToSend = testToSend.where((element) => element.source_ != null).toList();
|
||||||
|
var articleToSend = new ArticleDTO();
|
||||||
|
articleToSend.images = testToSend;
|
||||||
|
widget.onChanged(jsonEncode(articleToSend).toString());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
top: 10,
|
||||||
|
left: 10,
|
||||||
|
child: Text(
|
||||||
|
"Images",
|
||||||
|
style: TextStyle(fontSize: 15, fontWeight: FontWeight.w500),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
bottom: 15,
|
||||||
|
right: 15,
|
||||||
|
child: InkWell(
|
||||||
|
onTap: () async {
|
||||||
|
var result = await showNewOrUpdateImageSlider(null, appContext, context);
|
||||||
|
if (result != null)
|
||||||
|
{
|
||||||
|
setState(() {
|
||||||
|
result.order = articleDTO.images.length;
|
||||||
|
articleDTO.images.add(result);
|
||||||
|
widget.onChanged(jsonEncode(articleDTO).toString());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
height: MediaQuery.of(context).size.width * 0.04,
|
||||||
|
width: MediaQuery.of(context).size.width * 0.04,
|
||||||
|
child: Icon(
|
||||||
|
Icons.add,
|
||||||
|
color: kTextLightColor,
|
||||||
|
size: 30.0,
|
||||||
|
),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: kSuccess,
|
||||||
|
shape: BoxShape.rectangle,
|
||||||
|
borderRadius: BorderRadius.circular(20.0),
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: kSecond,
|
||||||
|
spreadRadius: 0.5,
|
||||||
|
blurRadius: 5,
|
||||||
|
offset: Offset(0, 1.5), // changes position of shadow
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -16,10 +16,12 @@ import 'package:managerapi/api.dart';
|
|||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
|
import 'SubSection/Article/article_config.dart';
|
||||||
import 'SubSection/Map/map_config.dart';
|
import 'SubSection/Map/map_config.dart';
|
||||||
import 'SubSection/Menu/menu_config.dart';
|
import 'SubSection/Menu/menu_config.dart';
|
||||||
import 'SubSection/Quizz/quizz_config.dart';
|
import 'SubSection/Quizz/quizz_config.dart';
|
||||||
import 'SubSection/Slider/slider_config.dart';
|
import 'SubSection/Slider/slider_config.dart';
|
||||||
|
import 'package:qr_flutter/qr_flutter.dart';
|
||||||
|
|
||||||
class SectionDetailScreen extends StatefulWidget {
|
class SectionDetailScreen extends StatefulWidget {
|
||||||
final String id;
|
final String id;
|
||||||
@ -184,15 +186,22 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
|
|||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
ImageInputContainer(
|
if(sectionDTO.type != SectionType.article)
|
||||||
label: "Image :",
|
ImageInputContainer(
|
||||||
initialValue: sectionDTO != null ? sectionDTO.imageId : "",
|
label: "Image :",
|
||||||
color: kPrimaryColor,
|
initialValue: sectionDTO != null ? sectionDTO.imageId : "",
|
||||||
onChanged: (ResourceDTO resource) {
|
color: kPrimaryColor,
|
||||||
sectionDTO.imageId = resource.id;
|
onChanged: (ResourceDTO resource) {
|
||||||
sectionDTO.imageSource = resource.type == ResourceType.imageUrl ? resource.data : appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ resource.id;
|
sectionDTO.imageId = resource.id;
|
||||||
},
|
sectionDTO.imageSource = resource.type == ResourceType.imageUrl ? resource.data : appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ resource.id;
|
||||||
)
|
},
|
||||||
|
)
|
||||||
|
else
|
||||||
|
QrImage(
|
||||||
|
data: sectionDTO.id,
|
||||||
|
version: QrVersions.auto,
|
||||||
|
size: 200.0,
|
||||||
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
@ -355,6 +364,17 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
|
|||||||
sectionDTO.data = data;
|
sectionDTO.data = data;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
case SectionType.article:
|
||||||
|
print(sectionDTO.data);
|
||||||
|
return ArticleConfig(
|
||||||
|
initialValue: sectionDTO.data,
|
||||||
|
onChanged: (String data) {
|
||||||
|
print("Received info in parent - article");
|
||||||
|
print(data);
|
||||||
|
sectionDTO.data = data;
|
||||||
|
save(false, sectionDTO, appContext);
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -116,7 +116,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
this.isRememberMe = widget.session.rememberMe;
|
this.isRememberMe = widget.session.rememberMe;
|
||||||
this.host = "http://192.168.1.19:8089"; //widget.session.host;
|
this.host = "http://localhost:5000"; //widget.session.host; // MDLF "http://192.168.1.19:8089"
|
||||||
this.email = "test@email.be"; //widget.session.email;
|
this.email = "test@email.be"; //widget.session.email;
|
||||||
this.password = "kljqsdkljqsd"; //widget.session.password;
|
this.password = "kljqsdkljqsd"; //widget.session.password;
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|||||||
14
pubspec.lock
14
pubspec.lock
@ -289,6 +289,20 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "5.0.0"
|
version: "5.0.0"
|
||||||
|
qr:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: qr
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.0"
|
||||||
|
qr_flutter:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: qr_flutter
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "4.0.0"
|
||||||
rxdart:
|
rxdart:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
|||||||
@ -40,6 +40,8 @@ dependencies:
|
|||||||
drag_and_drop_lists: ^0.3.2
|
drag_and_drop_lists: ^0.3.2
|
||||||
#path_provider: ^2.0.2
|
#path_provider: ^2.0.2
|
||||||
encrypt: ^5.0.0
|
encrypt: ^5.0.0
|
||||||
|
qr_flutter: ^4.0.0
|
||||||
|
pdf: ^3.8.1
|
||||||
#msix: ^2.1.3
|
#msix: ^2.1.3
|
||||||
#window_size:
|
#window_size:
|
||||||
# git:
|
# git:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user