Update beaconId as an integer
This commit is contained in:
parent
397e4fb6f2
commit
89502ce5d1
63
lib/Components/number_input_container.dart
Normal file
63
lib/Components/number_input_container.dart
Normal file
@ -0,0 +1,63 @@
|
||||
import 'package:auto_size_text/auto_size_text.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:manager_app/Components/rounded_input_field.dart';
|
||||
import 'package:manager_app/constants.dart';
|
||||
|
||||
class NumberInputContainer extends StatelessWidget {
|
||||
final Color color;
|
||||
final String label;
|
||||
final int initialValue;
|
||||
final ValueChanged<String> onChanged;
|
||||
final bool isUrl;
|
||||
final bool isSmall;
|
||||
final int maxLength;
|
||||
final double fontSize;
|
||||
final double fontSizeText;
|
||||
const NumberInputContainer({
|
||||
Key key,
|
||||
this.color = kSecond,
|
||||
this.label,
|
||||
this.initialValue,
|
||||
this.onChanged,
|
||||
this.isUrl = false,
|
||||
this.isSmall = false,
|
||||
this.maxLength = 50,
|
||||
this.fontSize = 25,
|
||||
this.fontSizeText = 20,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Size size = MediaQuery.of(context).size;
|
||||
return Container(
|
||||
child: Row(
|
||||
children: [
|
||||
Align(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: AutoSizeText(
|
||||
label,
|
||||
style: TextStyle(fontSize: fontSize, fontWeight: FontWeight.w300),
|
||||
maxLines: 2,
|
||||
maxFontSize: fontSize,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(10.0),
|
||||
child: Container(
|
||||
width: isUrl ? size.width *0.6 : isSmall ? size.width *0.1 : size.width *0.2,
|
||||
child: RoundedInputField(
|
||||
color: color,
|
||||
textColor: kBlack,
|
||||
fontSize: fontSizeText,
|
||||
initialValue: initialValue.toString(),
|
||||
onChanged: onChanged,
|
||||
maxLength: maxLength,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:manager_app/Components/text_field_container.dart';
|
||||
import 'package:manager_app/constants.dart';
|
||||
|
||||
@ -12,6 +13,7 @@ class RoundedInputField extends StatelessWidget {
|
||||
final bool isEmail;
|
||||
final double fontSize;
|
||||
final String autofill;
|
||||
final bool isInt;
|
||||
const RoundedInputField({
|
||||
Key key,
|
||||
this.hintText,
|
||||
@ -25,6 +27,7 @@ class RoundedInputField extends StatelessWidget {
|
||||
this.isEmail = false,
|
||||
this.fontSize = 20,
|
||||
this.autofill,
|
||||
this.isInt = false
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
@ -37,7 +40,10 @@ class RoundedInputField extends StatelessWidget {
|
||||
cursorColor: textColor,
|
||||
maxLength: maxLength,
|
||||
autofillHints: [autofill],
|
||||
keyboardType: isEmail ? TextInputType.emailAddress : TextInputType.text,
|
||||
keyboardType: isEmail ? TextInputType.emailAddress : isInt ? TextInputType.number : TextInputType.text,
|
||||
inputFormatters: !isInt ? [] : <TextInputFormatter>[
|
||||
FilteringTextInputFormatter.digitsOnly
|
||||
],
|
||||
style: TextStyle(fontSize: fontSize, color: textColor),
|
||||
decoration: InputDecoration(
|
||||
icon: icon != null ? Icon(
|
||||
|
||||
@ -6,6 +6,7 @@ import 'package:manager_app/Components/image_input_container.dart';
|
||||
import 'package:manager_app/Components/loading_common.dart';
|
||||
import 'package:manager_app/Components/message_notification.dart';
|
||||
import 'package:manager_app/Components/multi_string_input_container.dart';
|
||||
import 'package:manager_app/Components/number_input_container.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';
|
||||
@ -181,11 +182,17 @@ class _SectionDetailScreenState extends State<SectionDetailScreen> {
|
||||
},
|
||||
),
|
||||
if(sectionDTO.isBeacon)
|
||||
StringInputContainer(
|
||||
NumberInputContainer(
|
||||
label: "Identifiant Beacon :",
|
||||
initialValue: sectionDTO != null ? sectionDTO.beaconId : "",
|
||||
isSmall: true,
|
||||
onChanged: (value) {
|
||||
sectionDTO.beaconId = value;
|
||||
try {
|
||||
sectionDTO.beaconId = int.parse(value);
|
||||
} catch (e) {
|
||||
print('BeaconId not a number');
|
||||
showNotification(Colors.orange, kWhite, 'Cela doit être un chiffre', context, null);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user