mirror of
https://github.com/h7x4/Jisho-Study-Tool.git
synced 2024-12-21 21:47:29 +01:00
Fix language selector design
This commit is contained in:
parent
68357e7328
commit
16ca1d2a69
@ -2,19 +2,14 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class LanguageSelector extends StatefulWidget {
|
class LanguageSelector extends StatefulWidget {
|
||||||
final List<String> _languages;
|
|
||||||
|
|
||||||
LanguageSelector(this._languages);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
LanguageSelectorState createState() => new LanguageSelectorState(this._languages);
|
LanguageSelectorState createState() => new LanguageSelectorState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class LanguageSelectorState extends State<LanguageSelector> {
|
class LanguageSelectorState extends State<LanguageSelector> {
|
||||||
final List<String> _languages;
|
List<bool> isSelected;
|
||||||
List<bool> isSelected = [true, false, false];
|
|
||||||
|
|
||||||
LanguageSelectorState(this._languages);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -25,12 +20,20 @@ class LanguageSelectorState extends State<LanguageSelector> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ToggleButtons(
|
return ToggleButtons(
|
||||||
children: <Widget>[
|
isSelected: isSelected,
|
||||||
|
children: <Widget> [
|
||||||
LanguageOption("Auto"),
|
LanguageOption("Auto"),
|
||||||
LanguageOption("Japanese"),
|
LanguageOption("Japanese"),
|
||||||
LanguageOption("English")
|
LanguageOption("English")
|
||||||
],
|
],
|
||||||
isSelected: isSelected
|
selectedColor: Colors.blue,
|
||||||
|
onPressed: (int buttonIndex) {
|
||||||
|
setState(() {
|
||||||
|
for (var i in Iterable.generate(isSelected.length)) {
|
||||||
|
isSelected[i] = i == buttonIndex;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,14 +48,8 @@ class LanguageOption extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Expanded(
|
return Expanded(
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: EdgeInsets.symmetric(vertical: 10.0),
|
padding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 20.0),
|
||||||
child: Center(child: Text(_language)),
|
child: Center(child: Text(_language)),
|
||||||
decoration: BoxDecoration(
|
|
||||||
border: Border.all(
|
|
||||||
color: Colors.black,
|
|
||||||
width: 1.0,
|
|
||||||
),
|
|
||||||
color: Colors.white),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ class SearchBar extends StatelessWidget {
|
|||||||
SizedBox(
|
SizedBox(
|
||||||
height: 10.0,
|
height: 10.0,
|
||||||
),
|
),
|
||||||
LanguageSelector(["Auto", "Japanese", "English"])
|
LanguageSelector()
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user