112 lines
3.2 KiB
Dart
112 lines
3.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:manager_app/constants.dart';
|
|
import 'package:managerapi/api.dart';
|
|
class TranslationTab extends StatefulWidget {
|
|
final List<TranslationDTO> translations;
|
|
final int maxLines;
|
|
const TranslationTab({
|
|
Key key,
|
|
this.translations,
|
|
this.maxLines,
|
|
}) : super(key: key);
|
|
|
|
@override
|
|
_TranslationTabState createState() => _TranslationTabState();
|
|
}
|
|
|
|
class _TranslationTabState extends State<TranslationTab> with SingleTickerProviderStateMixin {
|
|
TabController _tabController;
|
|
|
|
@override
|
|
void initState() {
|
|
_tabController = new TabController(length: widget.translations.length, vsync: this);
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
body: Container(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
TabBar(
|
|
unselectedLabelColor: Colors.black,
|
|
labelColor: kPrimaryColor,
|
|
tabs: getTabs(widget.translations),
|
|
controller: _tabController,
|
|
indicatorSize: TabBarIndicatorSize.tab,
|
|
indicatorColor: kPrimaryColor,
|
|
),
|
|
Expanded(
|
|
child: TabBarView(
|
|
children: getContent(widget.translations, widget.maxLines),
|
|
controller: _tabController,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
getContent(List<TranslationDTO> translations, int maxLines) {
|
|
List<Widget> tabsToShow = new List<Widget>();
|
|
translations.forEach((translation) {
|
|
tabsToShow.add(
|
|
new Padding(
|
|
padding: EdgeInsets.symmetric(horizontal: 8, vertical: 16),
|
|
child: TextFormField (
|
|
keyboardType: TextInputType.multiline,
|
|
textInputAction: TextInputAction.newline,
|
|
minLines: 1,
|
|
maxLines: maxLines,
|
|
initialValue: translation.value,
|
|
onChanged: (String value) {
|
|
print("onChanged value in tranbslationTAB");
|
|
print(value);
|
|
translation.value = value;
|
|
},
|
|
cursorColor: kPrimaryColor,
|
|
decoration: InputDecoration(
|
|
enabledBorder: UnderlineInputBorder(
|
|
borderSide: BorderSide(color: kPrimaryColor),
|
|
),
|
|
focusedBorder: UnderlineInputBorder(
|
|
borderSide: BorderSide(color: kPrimaryColor),
|
|
),
|
|
border: UnderlineInputBorder(
|
|
borderSide: BorderSide(color: kPrimaryColor),
|
|
),
|
|
)
|
|
|
|
)
|
|
),
|
|
/*new Padding(
|
|
padding: const EdgeInsets.all(10.0),
|
|
child: Container(
|
|
width: 200,
|
|
child: RoundedInputField(
|
|
color: kSecond,
|
|
textColor: kBlack,
|
|
initialValue: translation.value,
|
|
onChanged: (String value) {
|
|
translation.value = value;
|
|
},
|
|
),
|
|
),
|
|
)*/
|
|
);
|
|
});
|
|
return tabsToShow;
|
|
}
|
|
|
|
getTabs(List<TranslationDTO> newValues) {
|
|
List<Tab> tabsToShow = new List<Tab>();
|
|
newValues.forEach((value) {
|
|
tabsToShow.add(
|
|
new Tab(text: value.language));
|
|
});
|
|
return tabsToShow;
|
|
} |