Minor improvements

This commit is contained in:
exttex 2020-11-01 20:23:24 +01:00
parent 563a460e48
commit 5725737385
6 changed files with 155 additions and 125 deletions

View file

@ -148,69 +148,79 @@ class _HomePageScreenState extends State<HomePageScreen> {
physics: NeverScrollableScrollPhysics(),
itemCount: _homePage.sections.length,
itemBuilder: (context, i) {
HomePageSection section = _homePage.sections[i];
return Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
child: Text(
section.title,
textAlign: TextAlign.left,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.w900
),
),
padding: EdgeInsets.symmetric(horizontal: 12.0, vertical: 8.0)
),
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
children: List.generate(section.items.length + 1, (i) {
//Has more items
if (i == section.items.length) {
if (section.hasMore??false) {
return FlatButton(
child: Text(
'Show more'.i18n,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 20.0
),
),
onPressed: () => Navigator.of(context).push(MaterialPageRoute(
builder: (context) => Scaffold(
appBar: FreezerAppBar(section.title),
body: SingleChildScrollView(
child: HomePageScreen(
channel: DeezerChannel(target: section.pagePath)
)
),
),
)),
);
}
return Container(height: 0, width: 0);
}
//Show item
HomePageItem item = section.items[i];
return HomePageItemWidget(item);
}),
),
),
Container(height: 8.0),
],
);
return HomepageSectionWidget(_homePage.sections[i]);
},
);
}
}
class HomepageSectionWidget extends StatelessWidget {
final HomePageSection section;
HomepageSectionWidget(this.section);
@override
Widget build(BuildContext context) {
return Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
child: Text(
section.title,
textAlign: TextAlign.left,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.w900
),
),
padding: EdgeInsets.symmetric(horizontal: 12.0, vertical: 8.0)
),
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
children: List.generate(section.items.length + 1, (i) {
//Has more items
if (i == section.items.length) {
if (section.hasMore??false) {
return FlatButton(
child: Text(
'Show more'.i18n,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 20.0
),
),
onPressed: () => Navigator.of(context).push(MaterialPageRoute(
builder: (context) => Scaffold(
appBar: FreezerAppBar(section.title),
body: SingleChildScrollView(
child: HomePageScreen(
channel: DeezerChannel(target: section.pagePath)
)
),
),
)),
);
}
return Container(height: 0, width: 0);
}
//Show item
HomePageItem item = section.items[i];
return HomePageItemWidget(item);
}),
),
),
Container(height: 8.0),
],
);
}
}
class HomePageItemWidget extends StatelessWidget {