Add local storage + update audioIds for Article + fix small layout bugs
This commit is contained in:
parent
d185c2c1e4
commit
99aaad3f50
@ -23,7 +23,7 @@ class AudioInputContainer extends StatefulWidget {
|
|||||||
this.onChanged,
|
this.onChanged,
|
||||||
this.imageFit = BoxFit.cover,
|
this.imageFit = BoxFit.cover,
|
||||||
this.isSmall = false,
|
this.isSmall = false,
|
||||||
this.fontSize = 25
|
this.fontSize = 20
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -138,8 +138,9 @@ class _AudioInputContainerState extends State<AudioInputContainer> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<ResourceDTO> getResource(String resourceIdToShow, dynamic appContext) async {
|
Future<ResourceDTO> getResource(String resourceIdToShow, dynamic appContext) async {
|
||||||
ResourceDTO resource = await appContext.getContext().clientAPI.resourceApi.resourceGetDetail(resourceIdToShow);
|
// Just in resource tab detail not here
|
||||||
return resource;
|
//ResourceDTO resource = await appContext.getContext().clientAPI.resourceApi.resourceGetDetail(resourceIdToShow);
|
||||||
|
return new ResourceDTO();
|
||||||
}
|
}
|
||||||
|
|
||||||
boxDecoration(ResourceDTO resourceDTO, appContext) {
|
boxDecoration(ResourceDTO resourceDTO, appContext) {
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import 'dart:typed_data';
|
|||||||
|
|
||||||
import 'package:audioplayers/audioplayers.dart';
|
import 'package:audioplayers/audioplayers.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:manager_app/Models/managerContext.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';
|
||||||
@ -178,7 +179,8 @@ class _AudioPlayerContainerState extends State<AudioPlayerContainer> {
|
|||||||
|
|
||||||
Future<Uint8List> getAudio(String resourceId, AppContext appContext) async {
|
Future<Uint8List> getAudio(String resourceId, AppContext appContext) async {
|
||||||
try {
|
try {
|
||||||
var url = "https://api.mymuseum.be/api/Resource/"+resourceId; // TO TEST TODO UPDATE ROUTE
|
ManagerAppContext managerAppContext = appContext.getContext() as ManagerAppContext;
|
||||||
|
var url = managerAppContext.host + "/api/Resource/" + resourceId; // TO TEST TODO UPDATE ROUTE
|
||||||
print("DOWNLOAD AUDDDDIOOOOO ------------");
|
print("DOWNLOAD AUDDDDIOOOOO ------------");
|
||||||
print(url);
|
print(url);
|
||||||
//HttpClient client2 = HttpClient();
|
//HttpClient client2 = HttpClient();
|
||||||
|
|||||||
@ -1,15 +1,21 @@
|
|||||||
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:auto_size_text/auto_size_text.dart';
|
import 'package:auto_size_text/auto_size_text.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:manager_app/Components/rounded_button.dart';
|
import 'package:manager_app/Components/rounded_button.dart';
|
||||||
import 'package:manager_app/Components/text_form_input_container.dart';
|
import 'package:manager_app/Components/text_form_input_container.dart';
|
||||||
import 'package:manager_app/Models/managerContext.dart';
|
import 'package:manager_app/Models/managerContext.dart';
|
||||||
|
import 'package:manager_app/Screens/Resources/select_resource_modal.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';
|
||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
showMultiStringInput (String label, String modalLabel, bool isTitle, List<TranslationDTO> values, List<TranslationDTO> newValues, Function onGetResult, int maxLines, BuildContext context) { /*Function onSelect,*/
|
import 'audio_input_container.dart';
|
||||||
|
|
||||||
|
|
||||||
|
showMultiStringInput (String label, String modalLabel, bool isTitle, List<TranslationDTO> values, List<TranslationDTO> newValues, Function onGetResult, int maxLines, bool isAudio, BuildContext context) { /*Function onSelect,*/
|
||||||
showDialog(
|
showDialog(
|
||||||
builder: (BuildContext context) => AlertDialog(
|
builder: (BuildContext context) => AlertDialog(
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
@ -23,7 +29,7 @@ showMultiStringInput (String label, String modalLabel, bool isTitle, List<Transl
|
|||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
children: getTranslations(context, Provider.of<AppContext>(context), label, isTitle, newValues),
|
children: getTranslations(context, Provider.of<AppContext>(context), label, isTitle, isAudio, newValues),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -84,7 +90,7 @@ showMultiStringInput (String label, String modalLabel, bool isTitle, List<Transl
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getTranslations(BuildContext context, AppContext appContext, String label, bool isTitle, List<TranslationDTO> newValues) {
|
getTranslations(BuildContext context, AppContext appContext, String label, bool isTitle, bool isAudio, List<TranslationDTO> newValues) {
|
||||||
List<Widget> translations = <Widget>[];
|
List<Widget> translations = <Widget>[];
|
||||||
ManagerAppContext managerAppContext = appContext.getContext();
|
ManagerAppContext managerAppContext = appContext.getContext();
|
||||||
for(var language in managerAppContext.selectedConfiguration.languages) {
|
for(var language in managerAppContext.selectedConfiguration.languages) {
|
||||||
@ -111,6 +117,7 @@ getTranslations(BuildContext context, AppContext appContext, String label, bool
|
|||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
|
!isAudio ?
|
||||||
TextFormInputContainer(
|
TextFormInputContainer(
|
||||||
label: label,
|
label: label,
|
||||||
color: kWhite,
|
color: kWhite,
|
||||||
@ -119,6 +126,18 @@ getTranslations(BuildContext context, AppContext appContext, String label, bool
|
|||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
newValues.where((element) => element.language == language).first.value = value;
|
newValues.where((element) => element.language == language).first.value = value;
|
||||||
},
|
},
|
||||||
|
) :
|
||||||
|
Container(
|
||||||
|
width: 250,
|
||||||
|
height: 120,
|
||||||
|
child: AudioInputContainer(
|
||||||
|
label: "Audio :",
|
||||||
|
initialValue: newValues.where((element) => element.language == language).first.value,
|
||||||
|
color: kPrimaryColor,
|
||||||
|
onChanged: (ResourceDTO resource) {
|
||||||
|
newValues.where((element) => element.language == language).first.value = resource.id;
|
||||||
|
},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -147,5 +166,3 @@ showValues(List<TranslationDTO> newValues) {
|
|||||||
});
|
});
|
||||||
return valuesToShow;
|
return valuesToShow;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -14,6 +14,7 @@ class MultiStringContainer extends StatelessWidget {
|
|||||||
final Function onGetResult;
|
final Function onGetResult;
|
||||||
final int maxLines;
|
final int maxLines;
|
||||||
final bool isTitle;
|
final bool isTitle;
|
||||||
|
final bool isAudio;
|
||||||
final double fontSize;
|
final double fontSize;
|
||||||
const MultiStringContainer({
|
const MultiStringContainer({
|
||||||
Key key,
|
Key key,
|
||||||
@ -24,6 +25,7 @@ class MultiStringContainer extends StatelessWidget {
|
|||||||
this.onGetResult,
|
this.onGetResult,
|
||||||
this.maxLines,
|
this.maxLines,
|
||||||
this.isTitle,
|
this.isTitle,
|
||||||
|
this.isAudio = false,
|
||||||
this.fontSize = 25,
|
this.fontSize = 25,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@ -56,7 +58,8 @@ class MultiStringContainer extends StatelessWidget {
|
|||||||
initialValue.forEach((value) {
|
initialValue.forEach((value) {
|
||||||
newValues.add(TranslationDTO.fromJson(jsonDecode(jsonEncode(value))));
|
newValues.add(TranslationDTO.fromJson(jsonDecode(jsonEncode(value))));
|
||||||
});
|
});
|
||||||
showMultiStringInput(label, modalLabel, isTitle, initialValue, newValues, onGetResult, maxLines, context);
|
|
||||||
|
showMultiStringInput(label, modalLabel, isTitle, initialValue, newValues, onGetResult, maxLines, isAudio, context);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
@ -68,7 +71,7 @@ class MultiStringContainer extends StatelessWidget {
|
|||||||
padding: const EdgeInsets.only(left: 5, right: 5, top: 15, bottom: 15),
|
padding: const EdgeInsets.only(left: 5, right: 5, top: 15, bottom: 15),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: AutoSizeText(
|
child: AutoSizeText(
|
||||||
"Changer les traductions",
|
isAudio ? "Changer audios" : "Changer traductions",
|
||||||
style: TextStyle(color: kWhite),
|
style: TextStyle(color: kWhite),
|
||||||
maxLines: 2,
|
maxLines: 2,
|
||||||
)
|
)
|
||||||
|
|||||||
@ -11,6 +11,7 @@ class RoundedInputField extends StatelessWidget {
|
|||||||
final int maxLength;
|
final int maxLength;
|
||||||
final bool isEmail;
|
final bool isEmail;
|
||||||
final double fontSize;
|
final double fontSize;
|
||||||
|
final String autofill;
|
||||||
const RoundedInputField({
|
const RoundedInputField({
|
||||||
Key key,
|
Key key,
|
||||||
this.hintText,
|
this.hintText,
|
||||||
@ -23,6 +24,7 @@ class RoundedInputField extends StatelessWidget {
|
|||||||
this.maxLength, // 50
|
this.maxLength, // 50
|
||||||
this.isEmail = false,
|
this.isEmail = false,
|
||||||
this.fontSize = 20,
|
this.fontSize = 20,
|
||||||
|
this.autofill,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -34,6 +36,7 @@ class RoundedInputField extends StatelessWidget {
|
|||||||
initialValue: initialValue,
|
initialValue: initialValue,
|
||||||
cursorColor: textColor,
|
cursorColor: textColor,
|
||||||
maxLength: maxLength,
|
maxLength: maxLength,
|
||||||
|
autofillHints: [autofill],
|
||||||
keyboardType: isEmail ? TextInputType.emailAddress : TextInputType.text,
|
keyboardType: isEmail ? TextInputType.emailAddress : TextInputType.text,
|
||||||
style: TextStyle(fontSize: fontSize, color: textColor),
|
style: TextStyle(fontSize: fontSize, color: textColor),
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
|
|||||||
@ -8,7 +8,7 @@ class RoundedPasswordField extends StatefulWidget {
|
|||||||
const RoundedPasswordField({
|
const RoundedPasswordField({
|
||||||
Key key,
|
Key key,
|
||||||
this.onChanged,
|
this.onChanged,
|
||||||
this.initialValue,
|
this.initialValue
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -25,6 +25,7 @@ class _RoundedPasswordFieldState extends State<RoundedPasswordField> {
|
|||||||
obscureText: isVisible,
|
obscureText: isVisible,
|
||||||
onChanged: widget.onChanged,
|
onChanged: widget.onChanged,
|
||||||
initialValue: widget.initialValue,
|
initialValue: widget.initialValue,
|
||||||
|
autofillHints: [AutofillHints.password],
|
||||||
cursorColor: kPrimaryColor,
|
cursorColor: kPrimaryColor,
|
||||||
style: TextStyle(fontSize: 20, color: kBlack),
|
style: TextStyle(fontSize: 20, color: kBlack),
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
|
|||||||
@ -66,7 +66,22 @@ class _UploadOnlineResourceContainerState extends State<UploadOnlineResourceCont
|
|||||||
return Image.network(
|
return Image.network(
|
||||||
urlResourceToShow,
|
urlResourceToShow,
|
||||||
height: 200,
|
height: 200,
|
||||||
fit:BoxFit.scaleDown
|
fit:BoxFit.scaleDown,
|
||||||
|
loadingBuilder: (BuildContext context, Widget child,
|
||||||
|
ImageChunkEvent loadingProgress) {
|
||||||
|
if (loadingProgress == null) {
|
||||||
|
return child;
|
||||||
|
}
|
||||||
|
return Center(
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
color: kPrimaryColor,
|
||||||
|
value: loadingProgress.expectedTotalBytes != null
|
||||||
|
? loadingProgress.cumulativeBytesLoaded /
|
||||||
|
loadingProgress.expectedTotalBytes
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import 'package:managerapi/api.dart';
|
|||||||
class ManagerAppContext with ChangeNotifier{
|
class ManagerAppContext with ChangeNotifier{
|
||||||
String email;
|
String email;
|
||||||
String instanceId;
|
String instanceId;
|
||||||
|
String host;
|
||||||
TokenDTO token;
|
TokenDTO token;
|
||||||
Client clientAPI;
|
Client clientAPI;
|
||||||
String currentRoute;
|
String currentRoute;
|
||||||
@ -18,6 +19,6 @@ class ManagerAppContext with ChangeNotifier{
|
|||||||
// Implement toString to make it easier to see information about
|
// Implement toString to make it easier to see information about
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'ManagerAppContext{email: $email, token: $token, currentRoute: $currentRoute}, selectedConfiguration: $selectedConfiguration, selectedSection: $selectedSection}';
|
return 'ManagerAppContext{email: $email, host: $host, token: $token, currentRoute: $currentRoute}, selectedConfiguration: $selectedConfiguration, selectedSection: $selectedSection}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -72,10 +72,12 @@ class _ArticleConfigState extends State<ArticleConfig> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
height: size.height * 0.1,
|
height: size.height * 0.15,
|
||||||
//width: size.width * 0.5,//,
|
//width: size.width * 0.5,//,
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
|
children: [
|
||||||
|
Column(
|
||||||
children: [
|
children: [
|
||||||
MultiStringContainer(
|
MultiStringContainer(
|
||||||
label: "Contenu affiché :",
|
label: "Contenu affiché :",
|
||||||
@ -105,14 +107,28 @@ class _ArticleConfigState extends State<ArticleConfig> {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
AudioInputContainer(
|
],
|
||||||
|
),
|
||||||
|
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
MultiStringContainer(
|
||||||
label: "Audio :",
|
label: "Audio :",
|
||||||
initialValue: articleDTO.audioId,
|
isAudio: true,
|
||||||
|
modalLabel: "Audio",
|
||||||
color: kPrimaryColor,
|
color: kPrimaryColor,
|
||||||
onChanged: (ResourceDTO resource) {
|
initialValue: articleDTO != null ? articleDTO.audioIds : [],
|
||||||
articleDTO.audioId = resource.id;
|
isTitle: false,
|
||||||
|
onGetResult: (value) {
|
||||||
|
setState(() {
|
||||||
|
if (articleDTO.audioIds != value) {
|
||||||
|
articleDTO.audioIds = value;
|
||||||
|
//save(true, articleDTO, appContext);
|
||||||
widget.onChanged(jsonEncode(articleDTO).toString());
|
widget.onChanged(jsonEncode(articleDTO).toString());
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
maxLines: 1,
|
||||||
),
|
),
|
||||||
CheckInputContainer(
|
CheckInputContainer(
|
||||||
label: "Lecture auto audio :",
|
label: "Lecture auto audio :",
|
||||||
@ -127,6 +143,8 @@ class _ArticleConfigState extends State<ArticleConfig> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
@ -141,7 +159,7 @@ class _ArticleConfigState extends State<ArticleConfig> {
|
|||||||
padding: const EdgeInsets.only(top: 40, left: 10, right: 10, bottom: 10),
|
padding: const EdgeInsets.only(top: 40, left: 10, right: 10, bottom: 10),
|
||||||
child: Container(
|
child: Container(
|
||||||
height: 250,
|
height: 250,
|
||||||
width: size.height * 0.95,
|
width: size.width * 0.95,
|
||||||
child: ReorderableListView(
|
child: ReorderableListView(
|
||||||
onReorder: _onReorder,
|
onReorder: _onReorder,
|
||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
@ -162,7 +180,7 @@ class _ArticleConfigState extends State<ArticleConfig> {
|
|||||||
testToSend = testToSend.where((element) => element.source_ != null).toList();
|
testToSend = testToSend.where((element) => element.source_ != null).toList();
|
||||||
var articleToSend = new ArticleDTO();
|
var articleToSend = new ArticleDTO();
|
||||||
articleToSend.images = testToSend;
|
articleToSend.images = testToSend;
|
||||||
articleToSend.audioId = articleDTO.audioId;
|
articleToSend.audioIds = articleDTO.audioIds;
|
||||||
articleToSend.isContentTop = articleDTO.isContentTop;
|
articleToSend.isContentTop = articleDTO.isContentTop;
|
||||||
articleToSend.content = articleDTO.content;
|
articleToSend.content = articleDTO.content;
|
||||||
articleToSend.isReadAudioAuto = articleDTO.isReadAudioAuto;
|
articleToSend.isReadAudioAuto = articleDTO.isReadAudioAuto;
|
||||||
|
|||||||
@ -83,7 +83,22 @@ class _ListViewCardGeoPointImagesState extends State<ListViewCardGeoPointImages>
|
|||||||
Center(
|
Center(
|
||||||
child: Image.network(
|
child: Image.network(
|
||||||
imageGeoPoint.imageSource,
|
imageGeoPoint.imageSource,
|
||||||
fit:BoxFit.scaleDown
|
fit:BoxFit.scaleDown,
|
||||||
|
loadingBuilder: (BuildContext context, Widget child,
|
||||||
|
ImageChunkEvent loadingProgress) {
|
||||||
|
if (loadingProgress == null) {
|
||||||
|
return child;
|
||||||
|
}
|
||||||
|
return Center(
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
color: kPrimaryColor,
|
||||||
|
value: loadingProgress.expectedTotalBytes != null
|
||||||
|
? loadingProgress.cumulativeBytesLoaded /
|
||||||
|
loadingProgress.expectedTotalBytes
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
/*Align(
|
/*Align(
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:html';
|
||||||
|
|
||||||
import 'package:auto_size_text/auto_size_text.dart';
|
import 'package:auto_size_text/auto_size_text.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:manager_app/Models/managerContext.dart';
|
import 'package:manager_app/Models/managerContext.dart';
|
||||||
@ -134,6 +136,8 @@ class _BodyState extends State<Body> {
|
|||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
print("Logout");
|
print("Logout");
|
||||||
|
Storage localStorage = window.localStorage;
|
||||||
|
localStorage.clear();
|
||||||
ManagerAppContext managerAppContext = appContext.getContext();
|
ManagerAppContext managerAppContext = appContext.getContext();
|
||||||
managerAppContext.token = null;
|
managerAppContext.token = null;
|
||||||
appContext.setContext(managerAppContext);
|
appContext.setContext(managerAppContext);
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import 'package:manager_app/Components/audio_player.dart';
|
import 'package:manager_app/Components/audio_player.dart';
|
||||||
import 'package:manager_app/app_context.dart';
|
import 'package:manager_app/app_context.dart';
|
||||||
|
import 'package:manager_app/constants.dart';
|
||||||
import 'package:managerapi/api.dart';
|
import 'package:managerapi/api.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
@ -8,13 +9,43 @@ getElementForResource(dynamic resourceDTO, AppContext appContext) {
|
|||||||
case ResourceType.image:
|
case ResourceType.image:
|
||||||
return Image.network(
|
return Image.network(
|
||||||
appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ resourceDTO.id,
|
appContext.getContext().clientAPI.resourceApi.apiClient.basePath+"/api/Resource/"+ resourceDTO.id,
|
||||||
fit:BoxFit.fill
|
fit:BoxFit.fill,
|
||||||
|
loadingBuilder: (BuildContext context, Widget child,
|
||||||
|
ImageChunkEvent loadingProgress) {
|
||||||
|
if (loadingProgress == null) {
|
||||||
|
return child;
|
||||||
|
}
|
||||||
|
return Center(
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
color: kPrimaryColor,
|
||||||
|
value: loadingProgress.expectedTotalBytes != null
|
||||||
|
? loadingProgress.cumulativeBytesLoaded /
|
||||||
|
loadingProgress.expectedTotalBytes
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case ResourceType.imageUrl:
|
case ResourceType.imageUrl:
|
||||||
return Image.network(
|
return Image.network(
|
||||||
resourceDTO.data,
|
resourceDTO.data,
|
||||||
fit:BoxFit.fill
|
fit:BoxFit.fill,
|
||||||
|
loadingBuilder: (BuildContext context, Widget child,
|
||||||
|
ImageChunkEvent loadingProgress) {
|
||||||
|
if (loadingProgress == null) {
|
||||||
|
return child;
|
||||||
|
}
|
||||||
|
return Center(
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
color: kPrimaryColor,
|
||||||
|
value: loadingProgress.expectedTotalBytes != null
|
||||||
|
? loadingProgress.cumulativeBytesLoaded /
|
||||||
|
loadingProgress.expectedTotalBytes
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case ResourceType.audio:
|
case ResourceType.audio:
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:file_picker/file_picker.dart';
|
import 'package:file_picker/file_picker.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:manager_app/Components/message_notification.dart';
|
import 'package:manager_app/Components/message_notification.dart';
|
||||||
import 'package:manager_app/Components/resource_tab.dart';
|
import 'package:manager_app/Components/resource_tab.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@ -89,11 +90,19 @@ dynamic showNewResource(AppContext appContext, BuildContext context) async {
|
|||||||
textColor: kWhite,
|
textColor: kWhite,
|
||||||
press: () {
|
press: () {
|
||||||
if (resourceDetailDTO.label != null && resourceDetailDTO.label.trim() != '') {
|
if (resourceDetailDTO.label != null && resourceDetailDTO.label.trim() != '') {
|
||||||
|
if(kIsWeb) {
|
||||||
|
if(resourceDetailDTO.data != null || filesToSendWeb != null) {
|
||||||
|
Navigator.pop(context, [resourceDetailDTO, filesToSend, filesToSendWeb]);
|
||||||
|
} else {
|
||||||
|
showNotification(Colors.orange, kWhite, 'Aucun fichier n\'a été chargé', context, null);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if (resourceDetailDTO.data != null || filesToSendWeb.length > 0 || filesToSend.length > 0) {
|
if (resourceDetailDTO.data != null || filesToSendWeb.length > 0 || filesToSend.length > 0) {
|
||||||
Navigator.pop(context, [resourceDetailDTO, filesToSend, filesToSendWeb]);
|
Navigator.pop(context, [resourceDetailDTO, filesToSend, filesToSendWeb]);
|
||||||
} else {
|
} else {
|
||||||
showNotification(Colors.orange, kWhite, 'Aucun fichier n\'a été chargé', context, null);
|
showNotification(Colors.orange, kWhite, 'Aucun fichier n\'a été chargé', context, null);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
showNotification(Colors.orange, kWhite, 'Veuillez donner un nom à la ressource', context, null);
|
showNotification(Colors.orange, kWhite, 'Veuillez donner un nom à la ressource', context, null);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import 'dart:html';
|
|||||||
|
|
||||||
import 'package:auto_size_text/auto_size_text.dart';
|
import 'package:auto_size_text/auto_size_text.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
import 'package:manager_app/Components/loading_common.dart';
|
import 'package:manager_app/Components/loading_common.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';
|
||||||
@ -34,6 +35,8 @@ class _LoginScreenState extends State<LoginScreen> {
|
|||||||
bool isLoading = false;
|
bool isLoading = false;
|
||||||
bool isRememberMe = false;
|
bool isRememberMe = false;
|
||||||
String pageTitle = "MyMuseum";
|
String pageTitle = "MyMuseum";
|
||||||
|
String token;
|
||||||
|
Storage localStorage = window.localStorage;
|
||||||
|
|
||||||
void authenticateTRY(dynamic appContext) async {
|
void authenticateTRY(dynamic appContext) async {
|
||||||
//print("try auth.. ");
|
//print("try auth.. ");
|
||||||
@ -44,7 +47,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
|||||||
|
|
||||||
clientAPI = Client(this.host);
|
clientAPI = Client(this.host);
|
||||||
|
|
||||||
if (this.email != null && this.password != null && this.host != null) {
|
if (this.email != null && this.password != null || this.token != null) {
|
||||||
|
|
||||||
// if () {} // Add if token exist and not null + not expired
|
// if () {} // Add if token exist and not null + not expired
|
||||||
try {
|
try {
|
||||||
@ -58,11 +61,25 @@ class _LoginScreenState extends State<LoginScreen> {
|
|||||||
TokenDTO token = await clientAPI.authenticationApi.authenticationAuthenticateWithJson(loginDTO);
|
TokenDTO token = await clientAPI.authenticationApi.authenticationAuthenticateWithJson(loginDTO);
|
||||||
setAccessToken(token.accessToken);
|
setAccessToken(token.accessToken);
|
||||||
|
|
||||||
if (isRememberMe) {
|
if(!isRememberMe) {
|
||||||
|
localStorage.clear();
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if(!localStorage.containsKey("remember")) {
|
||||||
|
localStorage.addEntries({"remember": "true"}.entries);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!localStorage.containsKey("email") && !localStorage.containsKey("token")) {
|
||||||
|
localStorage.addEntries({"email": email}.entries);
|
||||||
|
localStorage.addEntries({"token": token.accessToken}.entries);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Desktop
|
||||||
|
/*if (isRememberMe) {
|
||||||
Session updatedSession = new Session(rememberMe: isRememberMe, host: host, email: email, password: password);
|
Session updatedSession = new Session(rememberMe: isRememberMe, host: host, email: email, password: password);
|
||||||
// update JSON FILE
|
// update JSON FILE
|
||||||
FileHelper().writeSession(updatedSession);
|
FileHelper().writeSession(updatedSession);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
showNotification(kSuccess, kWhite, 'Connexion réussie', context, null);
|
showNotification(kSuccess, kWhite, 'Connexion réussie', context, null);
|
||||||
|
|
||||||
@ -74,6 +91,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
|||||||
|
|
||||||
// store user info locally
|
// store user info locally
|
||||||
managerAppContext.email = email;
|
managerAppContext.email = email;
|
||||||
|
managerAppContext.host = host;
|
||||||
managerAppContext.instanceId = token.instanceId;
|
managerAppContext.instanceId = token.instanceId;
|
||||||
managerAppContext.token = token;
|
managerAppContext.token = token;
|
||||||
managerAppContext.clientAPI = clientAPI;
|
managerAppContext.clientAPI = clientAPI;
|
||||||
@ -85,6 +103,14 @@ class _LoginScreenState extends State<LoginScreen> {
|
|||||||
isLoading = false;
|
isLoading = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//Navigator.pushNamed(context, '/main');
|
||||||
|
|
||||||
|
/*Navigator.pushNamedAndRemoveUntil(
|
||||||
|
context,
|
||||||
|
'/main',
|
||||||
|
(Route<dynamic> route) => false // For pushAndRemoveUntil
|
||||||
|
);*/
|
||||||
|
|
||||||
Navigator.pushAndRemoveUntil(
|
Navigator.pushAndRemoveUntil(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
@ -117,10 +143,20 @@ class _LoginScreenState extends State<LoginScreen> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
this.isRememberMe = widget.session.rememberMe;
|
//this.isRememberMe = widget.session.rememberMe;
|
||||||
this.host = "https://api.mymuseum.be"; // "http://localhost:5000" //widget.session.host; // MDLF "http://192.168.1.19:8089" // "https://api.mymuseum.be"
|
this.host = "http://localhost:5000"; // "http://localhost:5000" //widget.session.host; // MDLF "http://192.168.1.19:8089" // "https://api.mymuseum.be"
|
||||||
//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;
|
||||||
|
|
||||||
|
if(localStorage.containsKey("remember")) {
|
||||||
|
this.isRememberMe = true;
|
||||||
|
if(localStorage.containsKey("email")) {
|
||||||
|
this.email = localStorage.entries.where((element) => element.key == "email").first.value;
|
||||||
|
}
|
||||||
|
if(localStorage.containsKey("token")) {
|
||||||
|
this.token = localStorage.entries.where((element) => element.key == "token").first.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,6 +193,11 @@ class _LoginScreenState extends State<LoginScreen> {
|
|||||||
|
|
||||||
initInstance(appContext.getContext());
|
initInstance(appContext.getContext());
|
||||||
|
|
||||||
|
if(mounted && appContext != null && this.token != null)
|
||||||
|
{
|
||||||
|
this.authenticateTRY(appContext);
|
||||||
|
}
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
body: Center(
|
body: Center(
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
@ -208,10 +249,16 @@ class _LoginScreenState extends State<LoginScreen> {
|
|||||||
initialValue: host,
|
initialValue: host,
|
||||||
icon: Icons.home
|
icon: Icons.home
|
||||||
),*/
|
),*/
|
||||||
|
Form(
|
||||||
|
key: widget.key,
|
||||||
|
child: AutofillGroup(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: size.width*0.2,
|
width: size.width*0.2,
|
||||||
child: RoundedInputField(
|
child: RoundedInputField(
|
||||||
hintText: "E-mail",
|
hintText: "E-mail",
|
||||||
|
autofill: AutofillHints.email,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
email = value;
|
email = value;
|
||||||
},
|
},
|
||||||
@ -221,7 +268,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: size.width *0.2,
|
width: size.width*0.2,
|
||||||
child: RoundedPasswordField(
|
child: RoundedPasswordField(
|
||||||
initialValue: password,
|
initialValue: password,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
@ -229,7 +276,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if(!kIsWeb) Padding(
|
if(kIsWeb) Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: Row(
|
child: Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
@ -258,6 +305,7 @@ class _LoginScreenState extends State<LoginScreen> {
|
|||||||
vertical: 25,
|
vertical: 25,
|
||||||
horizontal: 45,
|
horizontal: 45,
|
||||||
press: () {
|
press: () {
|
||||||
|
TextInput.finishAutofillContext();
|
||||||
authenticateTRY(appContext);
|
authenticateTRY(appContext);
|
||||||
},
|
},
|
||||||
): Container(
|
): Container(
|
||||||
@ -265,6 +313,10 @@ class _LoginScreenState extends State<LoginScreen> {
|
|||||||
child: LoadingCommon()
|
child: LoadingCommon()
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
)
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -11,7 +11,7 @@ Name | Type | Description | Notes
|
|||||||
**content** | [**List<TranslationDTO>**](TranslationDTO.md) | | [optional] [default to const []]
|
**content** | [**List<TranslationDTO>**](TranslationDTO.md) | | [optional] [default to const []]
|
||||||
**qrCode** | **String** | | [optional]
|
**qrCode** | **String** | | [optional]
|
||||||
**isContentTop** | **bool** | | [optional]
|
**isContentTop** | **bool** | | [optional]
|
||||||
**audioId** | **String** | | [optional]
|
**audioIds** | [**List<TranslationDTO>**](TranslationDTO.md) | | [optional] [default to const []]
|
||||||
**isReadAudioAuto** | **bool** | | [optional]
|
**isReadAudioAuto** | **bool** | | [optional]
|
||||||
**images** | [**List<ImageDTO>**](ImageDTO.md) | | [optional] [default to const []]
|
**images** | [**List<ImageDTO>**](ImageDTO.md) | | [optional] [default to const []]
|
||||||
|
|
||||||
|
|||||||
@ -15,7 +15,7 @@ class ArticleDTO {
|
|||||||
this.content,
|
this.content,
|
||||||
this.qrCode,
|
this.qrCode,
|
||||||
this.isContentTop,
|
this.isContentTop,
|
||||||
this.audioId,
|
this.audioIds,
|
||||||
this.isReadAudioAuto,
|
this.isReadAudioAuto,
|
||||||
this.images,
|
this.images,
|
||||||
});
|
});
|
||||||
@ -26,7 +26,7 @@ class ArticleDTO {
|
|||||||
|
|
||||||
bool isContentTop;
|
bool isContentTop;
|
||||||
|
|
||||||
String audioId;
|
List<TranslationDTO> audioIds;
|
||||||
|
|
||||||
bool isReadAudioAuto;
|
bool isReadAudioAuto;
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ class ArticleDTO {
|
|||||||
other.content == content &&
|
other.content == content &&
|
||||||
other.qrCode == qrCode &&
|
other.qrCode == qrCode &&
|
||||||
other.isContentTop == isContentTop &&
|
other.isContentTop == isContentTop &&
|
||||||
other.audioId == audioId &&
|
other.audioIds == audioIds &&
|
||||||
other.isReadAudioAuto == isReadAudioAuto &&
|
other.isReadAudioAuto == isReadAudioAuto &&
|
||||||
other.images == images;
|
other.images == images;
|
||||||
|
|
||||||
@ -46,12 +46,12 @@ class ArticleDTO {
|
|||||||
(content == null ? 0 : content.hashCode) +
|
(content == null ? 0 : content.hashCode) +
|
||||||
(qrCode == null ? 0 : qrCode.hashCode) +
|
(qrCode == null ? 0 : qrCode.hashCode) +
|
||||||
(isContentTop == null ? 0 : isContentTop.hashCode) +
|
(isContentTop == null ? 0 : isContentTop.hashCode) +
|
||||||
(audioId == null ? 0 : audioId.hashCode) +
|
(audioIds == null ? 0 : audioIds.hashCode) +
|
||||||
(isReadAudioAuto == null ? 0 : isReadAudioAuto.hashCode) +
|
(isReadAudioAuto == null ? 0 : isReadAudioAuto.hashCode) +
|
||||||
(images == null ? 0 : images.hashCode);
|
(images == null ? 0 : images.hashCode);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() => 'ArticleDTO[content=$content, qrCode=$qrCode, isContentTop=$isContentTop, audioId=$audioId, isReadAudioAuto=$isReadAudioAuto, images=$images]';
|
String toString() => 'ArticleDTO[content=$content, qrCode=$qrCode, isContentTop=$isContentTop, audioIds=$audioIds, isReadAudioAuto=$isReadAudioAuto, images=$images]';
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
final json = <String, dynamic>{};
|
final json = <String, dynamic>{};
|
||||||
@ -64,8 +64,8 @@ class ArticleDTO {
|
|||||||
if (isContentTop != null) {
|
if (isContentTop != null) {
|
||||||
json[r'isContentTop'] = isContentTop;
|
json[r'isContentTop'] = isContentTop;
|
||||||
}
|
}
|
||||||
if (audioId != null) {
|
if (audioIds != null) {
|
||||||
json[r'audioId'] = audioId;
|
json[r'audioIds'] = audioIds;
|
||||||
}
|
}
|
||||||
if (isReadAudioAuto != null) {
|
if (isReadAudioAuto != null) {
|
||||||
json[r'isReadAudioAuto'] = isReadAudioAuto;
|
json[r'isReadAudioAuto'] = isReadAudioAuto;
|
||||||
@ -84,7 +84,7 @@ class ArticleDTO {
|
|||||||
content: TranslationDTO.listFromJson(json[r'content']),
|
content: TranslationDTO.listFromJson(json[r'content']),
|
||||||
qrCode: json[r'qrCode'],
|
qrCode: json[r'qrCode'],
|
||||||
isContentTop: json[r'isContentTop'],
|
isContentTop: json[r'isContentTop'],
|
||||||
audioId: json[r'audioId'],
|
audioIds: TranslationDTO.listFromJson(json[r'audioIds']),
|
||||||
isReadAudioAuto: json[r'isReadAudioAuto'],
|
isReadAudioAuto: json[r'isReadAudioAuto'],
|
||||||
images: ImageDTO.listFromJson(json[r'images']),
|
images: ImageDTO.listFromJson(json[r'images']),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -2107,9 +2107,11 @@ components:
|
|||||||
nullable: true
|
nullable: true
|
||||||
isContentTop:
|
isContentTop:
|
||||||
type: boolean
|
type: boolean
|
||||||
audioId:
|
audioIds:
|
||||||
type: string
|
type: array
|
||||||
nullable: true
|
nullable: true
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/TranslationDTO'
|
||||||
isReadAudioAuto:
|
isReadAudioAuto:
|
||||||
type: boolean
|
type: boolean
|
||||||
images:
|
images:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user