2022-11-03 10:55:39 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:photos/theme/ente_theme.dart';
|
|
|
|
|
2022-11-04 05:29:12 +00:00
|
|
|
class InfoItemWidget extends StatefulWidget {
|
2022-11-03 10:55:39 +00:00
|
|
|
final String hintText;
|
|
|
|
const InfoItemWidget({this.hintText = '', super.key});
|
|
|
|
|
2022-11-04 05:29:12 +00:00
|
|
|
@override
|
|
|
|
State<InfoItemWidget> createState() => _InfoItemWidgetState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _InfoItemWidgetState extends State<InfoItemWidget> {
|
|
|
|
int maxLength = 280;
|
|
|
|
int currentLength = 0;
|
2022-11-04 09:23:04 +00:00
|
|
|
final _textController = TextEditingController();
|
|
|
|
final _focusNode = FocusNode();
|
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
// save caption here
|
|
|
|
_textController.dispose();
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
|
2022-11-03 10:55:39 +00:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final colorScheme = getEnteColorScheme(context);
|
2022-11-04 05:29:12 +00:00
|
|
|
final textTheme = getEnteTextTheme(context);
|
2022-11-03 10:55:39 +00:00
|
|
|
return TextField(
|
2022-11-04 09:23:04 +00:00
|
|
|
onEditingComplete: () {
|
|
|
|
//save caption here
|
|
|
|
_focusNode.unfocus();
|
|
|
|
},
|
|
|
|
controller: _textController,
|
|
|
|
focusNode: _focusNode,
|
2022-11-03 10:55:39 +00:00
|
|
|
decoration: InputDecoration(
|
2022-11-04 05:29:12 +00:00
|
|
|
counterStyle: textTheme.mini.copyWith(color: colorScheme.textMuted),
|
|
|
|
counterText: currentLength > 99
|
|
|
|
? currentLength.toString() + " / " + maxLength.toString()
|
2022-11-04 05:42:54 +00:00
|
|
|
: "",
|
2022-11-03 10:55:39 +00:00
|
|
|
contentPadding: const EdgeInsets.all(16),
|
|
|
|
border: InputBorder.none,
|
|
|
|
focusedBorder: InputBorder.none,
|
|
|
|
filled: true,
|
|
|
|
fillColor: colorScheme.fillFaint,
|
2022-11-04 05:29:12 +00:00
|
|
|
hintText: widget.hintText,
|
2022-11-03 10:55:39 +00:00
|
|
|
hintStyle: getEnteTextTheme(context)
|
|
|
|
.small
|
|
|
|
.copyWith(color: colorScheme.textMuted),
|
|
|
|
),
|
|
|
|
style: getEnteTextTheme(context).small,
|
|
|
|
cursorWidth: 1.5,
|
2022-11-04 05:29:12 +00:00
|
|
|
maxLength: maxLength,
|
2022-11-04 09:23:04 +00:00
|
|
|
minLines: 1,
|
|
|
|
maxLines: 6,
|
|
|
|
keyboardType: TextInputType.text,
|
2022-11-04 05:29:12 +00:00
|
|
|
onChanged: (value) {
|
|
|
|
setState(() {
|
|
|
|
currentLength = value.length;
|
|
|
|
});
|
|
|
|
},
|
2022-11-03 10:55:39 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|