one service listview

This commit is contained in:
Daniel Borges 2019-08-06 10:34:02 -03:00
parent 821b95e442
commit f9c97303a3
3 changed files with 25 additions and 125 deletions

View File

@ -5,7 +5,6 @@ import 'app_theme.dart';
import 'widgets/bottom_navigation_bar.dart';
import 'widgets/search_floating_button.dart';
import 'widgets/service_listview.dart';
import 'widgets/service_listview_v2.dart';
class OpenLPRemoteApp extends StatefulWidget {
@override
@ -19,7 +18,7 @@ class _OpenLPRemoteAppState extends State<OpenLPRemoteApp>
@override
void initState() {
super.initState();
tabController = TabController(length: 3, vsync: this);
tabController = TabController(length: 2, vsync: this);
}
@override
@ -40,7 +39,6 @@ class _OpenLPRemoteAppState extends State<OpenLPRemoteApp>
bottom: TabBar(
tabs: <Widget>[
Tab(text: 'SERVICE'),
Tab(text: 'SERVICE V2'),
Tab(text: 'SLIDES'),
],
controller: tabController,
@ -50,7 +48,6 @@ class _OpenLPRemoteAppState extends State<OpenLPRemoteApp>
controller: tabController,
children: <Widget>[
ServiceListView(),
ServiceListViewV2(),
Container(),
],
),

View File

@ -54,43 +54,30 @@ class _ServiceListViewState extends State<ServiceListView> {
itemCount: serviceItems.length,
itemBuilder: (context, i) {
ServiceItem item = serviceItems[i];
return Padding(
padding:
EdgeInsets.all(item.selected ? 15 : 25).copyWith(bottom: 0),
child: Card(
elevation: item.selected ? 10 : 1,
child: InkWell(
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
AspectRatio(
aspectRatio: 3 / 1,
child: Container(
color: Colors.black12,
child: item.plugin.id == 'images'
? FittedBox(
child:
Image.network('https://picsum.photos/500'),
fit: BoxFit.cover,
)
: Icon(item.plugin.icon()),
),
),
ListTile(
title: Text(item.title),
trailing: IconButton(
icon: Icon(
Icons.delete,
color: Colors.red,
),
onPressed: () {},
),
),
],
),
onTap: () {},
),
));
return ListTile(
contentPadding: EdgeInsets.all(10),
selected: item.selected,
leading: ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(7)),
child: Container(
height: 50,
width: 50,
child: item.plugin.id == 'images'
? FittedBox(
child: Image.network('https://picsum.photos/500'),
fit: BoxFit.cover,
)
: Icon(item.plugin.icon()),
),
),
title: Text(item.title),
subtitle: Text(item.plugin.id),
trailing: IconButton(
icon: Icon(Icons.delete),
onPressed: () {},
),
onTap: () {},
);
},
);
}

View File

@ -1,84 +0,0 @@
import 'package:flutter/material.dart';
import '../models/service_item.dart';
class ServiceListViewV2 extends StatefulWidget {
@override
_ServiceListViewV2State createState() => _ServiceListViewV2State();
}
class _ServiceListViewV2State extends State<ServiceListViewV2> {
List<ServiceItem> serviceItems;
@override
void initState() {
serviceItems = [
ServiceItem(id: '1', plugin: 'songs', selected: false, title: 'Oceans'),
ServiceItem(
id: '2', plugin: 'bibles', selected: true, title: 'John 3:16'),
ServiceItem(
id: '3',
plugin: 'presentations',
selected: false,
title: 'Sunday service.pdf'),
ServiceItem(
id: '4', plugin: 'images', selected: false, title: 'Slogan.jpg'),
ServiceItem(
id: '5', plugin: 'media', selected: false, title: 'Video.mp4'),
ServiceItem(
id: '6', plugin: 'custom', selected: false, title: 'Custom alert'),
];
super.initState();
}
@override
Widget build(BuildContext context) {
if (serviceItems.isEmpty) {
return Center(
child: Container(
constraints: BoxConstraints(
maxHeight: 100,
maxWidth: 250,
),
child: Text(
'Any item added to service.\n' +
'Please, add a new service item tapping the "New service item" button.',
textAlign: TextAlign.center,
style: TextStyle(color: Colors.black38),
),
),
);
}
return ListView.builder(
padding: EdgeInsets.only(bottom: 35),
itemCount: serviceItems.length,
itemBuilder: (context, i) {
ServiceItem item = serviceItems[i];
return ListTile(
contentPadding: EdgeInsets.all(10),
selected: item.selected,
leading: ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(7)),
child: Container(
height: 50,
width: 50,
child: item.plugin.id == 'images'
? FittedBox(
child: Image.network('https://picsum.photos/500'),
fit: BoxFit.cover,
)
: Icon(item.plugin.icon()),
),
),
title: Text(item.title),
subtitle: Text(item.plugin.id),
trailing: IconButton(
icon: Icon(Icons.delete),
onPressed: () {},
),
onTap: () {},
);
},
);
}
}