1
0
mirror of https://github.com/h7x4/Jisho-Study-Tool.git synced 2024-12-21 05:27:29 +01:00

Fix language selector design

This commit is contained in:
Oystein Kristoffer Tveit 2021-03-02 23:35:47 +01:00
parent 68357e7328
commit 16ca1d2a69
2 changed files with 14 additions and 17 deletions

View File

@ -2,19 +2,14 @@
import 'package:flutter/material.dart';
class LanguageSelector extends StatefulWidget {
final List<String> _languages;
LanguageSelector(this._languages);
@override
LanguageSelectorState createState() => new LanguageSelectorState(this._languages);
LanguageSelectorState createState() => new LanguageSelectorState();
}
class LanguageSelectorState extends State<LanguageSelector> {
final List<String> _languages;
List<bool> isSelected = [true, false, false];
LanguageSelectorState(this._languages);
List<bool> isSelected;
@override
void initState() {
@ -25,12 +20,20 @@ class LanguageSelectorState extends State<LanguageSelector> {
@override
Widget build(BuildContext context) {
return ToggleButtons(
children: <Widget>[
isSelected: isSelected,
children: <Widget> [
LanguageOption("Auto"),
LanguageOption("Japanese"),
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) {
return Expanded(
child: Container(
padding: EdgeInsets.symmetric(vertical: 10.0),
padding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 20.0),
child: Center(child: Text(_language)),
decoration: BoxDecoration(
border: Border.all(
color: Colors.black,
width: 1.0,
),
color: Colors.white),
),
);
}

View File

@ -68,7 +68,7 @@ class SearchBar extends StatelessWidget {
SizedBox(
height: 10.0,
),
LanguageSelector(["Auto", "Japanese", "English"])
LanguageSelector()
],
),
);