added scroll controller in forms
This commit is contained in:
parent
99b207253b
commit
d323eec8ed
|
|
@ -16,6 +16,7 @@ class OperatingSystemSelection extends StatefulWidget {
|
||||||
class _OperatingSystemSelectionState extends State<OperatingSystemSelection> {
|
class _OperatingSystemSelectionState extends State<OperatingSystemSelection> {
|
||||||
var term = "";
|
var term = "";
|
||||||
final focusNode = FocusNode();
|
final focusNode = FocusNode();
|
||||||
|
final ScrollController _scrollController = ScrollController();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
|
@ -23,6 +24,12 @@ class _OperatingSystemSelectionState extends State<OperatingSystemSelection> {
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_scrollController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
|
|
@ -63,64 +70,56 @@ class _OperatingSystemSelectionState extends State<OperatingSystemSelection> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
body: SingleChildScrollView(
|
body: Scrollbar(
|
||||||
child: Column(
|
controller: _scrollController,
|
||||||
children: [
|
child: FutureBuilder(
|
||||||
FutureBuilder(
|
future: gOperatingSystems,
|
||||||
future: gOperatingSystems,
|
builder: (BuildContext context, AsyncSnapshot<List> snapshot) {
|
||||||
builder: (BuildContext context, AsyncSnapshot<List> snapshot) {
|
if (snapshot.hasData) {
|
||||||
if (snapshot.hasData) {
|
List list = snapshot.data!
|
||||||
List list = snapshot.data!
|
.where((os) =>
|
||||||
.where((os) => os.name.toLowerCase().contains(term.toLowerCase()))
|
os.name.toLowerCase().contains(term.toLowerCase()))
|
||||||
.toList();
|
.toList();
|
||||||
return ListView.builder(
|
return ListView.builder(
|
||||||
padding: const EdgeInsets.only(top: 4),
|
controller: _scrollController,
|
||||||
shrinkWrap: true,
|
itemCount: list.length,
|
||||||
itemCount: list.length,
|
itemBuilder: (context, index) {
|
||||||
itemBuilder: (context, index) {
|
var item = list[index];
|
||||||
var item = list[index];
|
Widget icon;
|
||||||
Widget icon;
|
|
||||||
|
|
||||||
if (osIcons.containsKey(item.code)) {
|
if (osIcons.containsKey(item.code)) {
|
||||||
icon = SvgPicture.asset(
|
icon = SvgPicture.asset(
|
||||||
osIcons[item.code]!,
|
osIcons[item.code]!,
|
||||||
width: 32,
|
width: 32,
|
||||||
height: 32,
|
height: 32,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// Replace with generic icon
|
icon = const Icon(Icons.computer, size: 32);
|
||||||
icon = const Icon(Icons.computer, size: 32);
|
}
|
||||||
}
|
return Card(
|
||||||
return Card(
|
child: ListTile(
|
||||||
child: ListTile(
|
title: Text(item.name),
|
||||||
title: Text(item.name),
|
leading: icon,
|
||||||
leading: icon,
|
onTap: () {
|
||||||
onTap: () {
|
Navigator.of(context).pop(item);
|
||||||
Navigator.of(context).pop(item);
|
},
|
||||||
},
|
),
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
} else {
|
},
|
||||||
return Row(
|
);
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
} else {
|
||||||
children: [
|
return Center(
|
||||||
Column(
|
child: Column(
|
||||||
children: [
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
const Padding(
|
children: [
|
||||||
padding: EdgeInsets.all(16.0),
|
const CircularProgressIndicator(),
|
||||||
child: CircularProgressIndicator()
|
const SizedBox(height: 16),
|
||||||
),
|
Text(context.t('Loading available downloads')),
|
||||||
Text(context.t('Loading available downloads')),
|
],
|
||||||
],
|
),
|
||||||
)
|
);
|
||||||
],
|
}
|
||||||
);
|
},
|
||||||
}
|
|
||||||
}
|
|
||||||
),
|
|
||||||
]
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ class OptionSelection extends StatefulWidget {
|
||||||
class _OptionSelectionState extends State<OptionSelection> {
|
class _OptionSelectionState extends State<OptionSelection> {
|
||||||
var term = "";
|
var term = "";
|
||||||
final focusNode = FocusNode();
|
final focusNode = FocusNode();
|
||||||
|
final ScrollController _scrollController = ScrollController();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
|
@ -22,6 +23,12 @@ class _OptionSelectionState extends State<OptionSelection> {
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_scrollController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var list = widget.version.options
|
var list = widget.version.options
|
||||||
|
|
@ -68,25 +75,22 @@ class _OptionSelectionState extends State<OptionSelection> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
body: SingleChildScrollView(
|
body: Scrollbar(
|
||||||
child: Column(
|
controller: _scrollController,
|
||||||
children: [
|
child: ListView.builder(
|
||||||
ListView.builder(
|
controller: _scrollController,
|
||||||
shrinkWrap: true,
|
itemCount: list.length,
|
||||||
itemCount: list.length,
|
itemBuilder: (context, index) {
|
||||||
itemBuilder: (context, index) {
|
var item = list[index];
|
||||||
var item = list[index];
|
return Card(
|
||||||
return Card(
|
child: ListTile(
|
||||||
child: ListTile(
|
title: Text(item.option),
|
||||||
title: Text(item.option),
|
onTap: () {
|
||||||
onTap: () {
|
Navigator.of(context).pop(item);
|
||||||
Navigator.of(context).pop(item);
|
},
|
||||||
},
|
),
|
||||||
),
|
);
|
||||||
);
|
},
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ class VersionSelection extends StatefulWidget {
|
||||||
class _VersionSelectionState extends State<VersionSelection> {
|
class _VersionSelectionState extends State<VersionSelection> {
|
||||||
var term = "";
|
var term = "";
|
||||||
final focusNode = FocusNode();
|
final focusNode = FocusNode();
|
||||||
|
final ScrollController _scrollController = ScrollController();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
|
@ -26,6 +27,12 @@ class _VersionSelectionState extends State<VersionSelection> {
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_scrollController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var list = widget.operatingSystem.versions
|
var list = widget.operatingSystem.versions
|
||||||
|
|
@ -73,41 +80,37 @@ class _VersionSelectionState extends State<VersionSelection> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
body: SingleChildScrollView(
|
body: Scrollbar(
|
||||||
child: Column(
|
controller: _scrollController,
|
||||||
children: [
|
child: ListView.builder(
|
||||||
ListView.builder(
|
controller: _scrollController,
|
||||||
padding: const EdgeInsets.only(top: 4),
|
padding: const EdgeInsets.only(top: 4),
|
||||||
shrinkWrap: true,
|
itemCount: list.length,
|
||||||
itemCount: list.length,
|
itemBuilder: (context, index) {
|
||||||
itemBuilder: (context, index) {
|
var item = list[index];
|
||||||
var item = list[index];
|
return Card(
|
||||||
return Card(
|
child: ListTile(
|
||||||
child: ListTile(
|
title: Text(item.version),
|
||||||
title: Text(item.version),
|
onTap: () {
|
||||||
onTap: () {
|
if (item.options.length > 1) {
|
||||||
if (item.options.length > 1) {
|
Navigator.of(context)
|
||||||
|
.push<Option>(MaterialPageRoute(
|
||||||
|
fullscreenDialog: true,
|
||||||
|
builder: (context) => OptionSelection(list[index])))
|
||||||
|
.then((selection) {
|
||||||
|
if (selection != null) {
|
||||||
Navigator.of(context)
|
Navigator.of(context)
|
||||||
.push<Option>(MaterialPageRoute(
|
.pop(Tuple2<Version, Option?>(item, selection));
|
||||||
fullscreenDialog: true,
|
|
||||||
builder: (context) =>
|
|
||||||
OptionSelection(list[index])))
|
|
||||||
.then((selection) {
|
|
||||||
if (selection != null) {
|
|
||||||
Navigator.of(context)
|
|
||||||
.pop(Tuple2<Version, Option?>(item, selection));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
Navigator.of(context).pop(Tuple2<Version, Option?>(
|
|
||||||
item, list[index].options[0]));
|
|
||||||
}
|
}
|
||||||
},
|
});
|
||||||
),
|
} else {
|
||||||
);
|
Navigator.of(context).pop(
|
||||||
},
|
Tuple2<Version, Option?>(item, list[index].options[0]));
|
||||||
),
|
}
|
||||||
],
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue