86 lines
2.5 KiB
Dart
86 lines
2.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../models/service_item.dart';
|
|
|
|
class ServiceListView extends StatefulWidget {
|
|
@override
|
|
_ServiceListViewState createState() => _ServiceListViewState();
|
|
}
|
|
|
|
class _ServiceListViewState extends State<ServiceListView> {
|
|
List<ServiceItem> serviceItems;
|
|
|
|
@override
|
|
void initState() {
|
|
serviceItems = [
|
|
ServiceItem(id: '1', plugin: 'songs', selected: true, title: 'Oceans'),
|
|
ServiceItem(
|
|
id: '2', plugin: 'bibles', selected: false, 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'),
|
|
];
|
|
// serviceItems = [];
|
|
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: () {},
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|