Change translations layout - slider
This commit is contained in:
parent
3ecf85d35e
commit
8990d0fcd6
@ -46,7 +46,7 @@ class _ImageInputContainerState extends State<ImageInputContainer> {
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: Container(
|
||||
width: size.width *0.2,
|
||||
width: size.width *0.10,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
showSelectResourceModal(
|
||||
|
||||
@ -32,7 +32,7 @@ class StringInputContainer extends StatelessWidget {
|
||||
child: Container(
|
||||
width: isUrl ? size.width *0.6 : size.width *0.2,
|
||||
child: RoundedInputField(
|
||||
color: kSecond,
|
||||
color: color,
|
||||
textColor: kBlack,
|
||||
initialValue: initialValue,
|
||||
onChanged: onChanged,
|
||||
|
||||
69
lib/Components/text_form_input_container.dart
Normal file
69
lib/Components/text_form_input_container.dart
Normal file
@ -0,0 +1,69 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:manager_app/Components/rounded_input_field.dart';
|
||||
import 'package:manager_app/constants.dart';
|
||||
|
||||
class TextFormInputContainer extends StatelessWidget {
|
||||
final Color color;
|
||||
final String label;
|
||||
final String initialValue;
|
||||
final bool isTitle;
|
||||
final ValueChanged<String> onChanged;
|
||||
const TextFormInputContainer({
|
||||
Key key,
|
||||
this.color = kSecond,
|
||||
this.label,
|
||||
this.initialValue,
|
||||
this.isTitle,
|
||||
this.onChanged
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Size size = MediaQuery.of(context).size;
|
||||
return Container(
|
||||
child: Row(
|
||||
children: [
|
||||
Align(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: Text(label, style: TextStyle(fontSize: 20, fontWeight: FontWeight.w300))
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: color,
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
border: Border.all(width: 0.5, color: kSecond)
|
||||
),
|
||||
width: size.width *0.3,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: TextFormField (
|
||||
keyboardType: TextInputType.multiline,
|
||||
textInputAction: TextInputAction.newline,
|
||||
minLines: 1,
|
||||
maxLines: 5,
|
||||
initialValue: initialValue,
|
||||
onChanged: onChanged,
|
||||
maxLength: isTitle ? 50 : 2000,
|
||||
cursorColor: kPrimaryColor,
|
||||
decoration: InputDecoration(
|
||||
enabledBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: kPrimaryColor),
|
||||
),
|
||||
focusedBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: kSecond),
|
||||
),
|
||||
border: UnderlineInputBorder(
|
||||
borderSide: BorderSide(color: kPrimaryColor),
|
||||
),
|
||||
)
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,7 +1,8 @@
|
||||
import 'package:auto_size_text/auto_size_text.dart';
|
||||
import 'package:manager_app/Components/image_input_container.dart';
|
||||
import 'package:manager_app/Components/multi_string_input_container.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:manager_app/Components/rounded_button.dart';
|
||||
import 'package:manager_app/Components/text_form_input_container.dart';
|
||||
import 'package:manager_app/Models/managerContext.dart';
|
||||
import 'package:manager_app/app_context.dart';
|
||||
import 'package:manager_app/constants.dart';
|
||||
@ -11,7 +12,6 @@ void showNewOrUpdateImageSlider(ImageDTO inputImageDTO, Function getResult, AppC
|
||||
ImageDTO imageDTO = new ImageDTO();
|
||||
|
||||
if (inputImageDTO != null) {
|
||||
print("inputImageDTO.source_ != null NOT NULLLLL");
|
||||
imageDTO = inputImageDTO;
|
||||
} else {
|
||||
imageDTO.title = <TranslationDTO>[];
|
||||
@ -27,8 +27,6 @@ void showNewOrUpdateImageSlider(ImageDTO inputImageDTO, Function getResult, AppC
|
||||
});
|
||||
}
|
||||
|
||||
print(imageDTO);
|
||||
|
||||
Size size = MediaQuery.of(context).size;
|
||||
showDialog(
|
||||
builder: (BuildContext context) => AlertDialog(
|
||||
@ -40,7 +38,7 @@ void showNewOrUpdateImageSlider(ImageDTO inputImageDTO, Function getResult, AppC
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
Text("Nouvelle image/vidéo", style: new TextStyle(fontSize: 25, fontWeight: FontWeight.w400)),
|
||||
Text("Image/vidéo", style: new TextStyle(fontSize: 25, fontWeight: FontWeight.w400)),
|
||||
Column(
|
||||
children: [
|
||||
ImageInputContainer(
|
||||
@ -52,33 +50,13 @@ void showNewOrUpdateImageSlider(ImageDTO inputImageDTO, Function getResult, AppC
|
||||
imageDTO.resourceId = resource.id;
|
||||
},
|
||||
),
|
||||
MultiStringContainer(
|
||||
label: "Titre :",
|
||||
color: kPrimaryColor,
|
||||
initialValue: imageDTO.title,
|
||||
onGetResult: (value) {
|
||||
print("Received titres");
|
||||
|
||||
if (imageDTO.title != value) {
|
||||
imageDTO.title = value;
|
||||
}
|
||||
print(imageDTO.title);
|
||||
},
|
||||
maxLines: 1,
|
||||
),
|
||||
MultiStringContainer(
|
||||
label: "Description :",
|
||||
color: kPrimaryColor,
|
||||
initialValue: imageDTO.description,
|
||||
onGetResult: (value) {
|
||||
print("Received descriptions");
|
||||
print(value);
|
||||
if (imageDTO.description != value) {
|
||||
imageDTO.description = value;
|
||||
}
|
||||
print(imageDTO.description);
|
||||
},
|
||||
maxLines: 1,
|
||||
Container(
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: getTranslations(context, appContext, imageDTO),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@ -117,10 +95,7 @@ void showNewOrUpdateImageSlider(ImageDTO inputImageDTO, Function getResult, AppC
|
||||
color: kPrimaryColor,
|
||||
textColor: kWhite,
|
||||
press: () {
|
||||
print("TODO create or update");
|
||||
print(imageDTO);
|
||||
getResult(imageDTO);
|
||||
print("result sent");
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
fontSize: 20,
|
||||
@ -134,3 +109,60 @@ void showNewOrUpdateImageSlider(ImageDTO inputImageDTO, Function getResult, AppC
|
||||
);
|
||||
}
|
||||
|
||||
getTranslations(BuildContext context, AppContext appContext, ImageDTO imageDTO) {
|
||||
List<Widget> translations = <Widget>[];
|
||||
ManagerAppContext managerAppContext = appContext.getContext();
|
||||
for(var language in managerAppContext.selectedConfiguration.languages) {
|
||||
translations.add(
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
width: MediaQuery.of(context).size.width *0.05,
|
||||
height: MediaQuery.of(context).size.height *0.2,
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
right: BorderSide(width: 1.5, color: kSecond),
|
||||
),
|
||||
),
|
||||
child: Center(child: AutoSizeText(language.toUpperCase()))
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0),
|
||||
child: Container(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
TextFormInputContainer(
|
||||
label: "Titre:",
|
||||
color: kWhite,
|
||||
isTitle: true,
|
||||
initialValue: imageDTO.title.where((element) => element.language == language).first.value,
|
||||
onChanged: (value) {
|
||||
imageDTO.title.where((element) => element.language == language).first.value = value;
|
||||
},
|
||||
),
|
||||
TextFormInputContainer(
|
||||
label: "Description:",
|
||||
color: kWhite,
|
||||
isTitle: false,
|
||||
initialValue: imageDTO.description.where((element) => element.language == language).first.value,
|
||||
onChanged: (value) {
|
||||
imageDTO.description.where((element) => element.language == language).first.value = value;
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
return translations;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user