mirror of
https://gitlab.com/openlp/openlp-mobile-remote.git
synced 2024-12-22 20:02:53 +00:00
first app skeleton
This commit is contained in:
parent
f99df63153
commit
c4e2a7977b
8
lib/app_theme.dart
Normal file
8
lib/app_theme.dart
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
Color _blue = Color(0xFF3D6ABD);
|
||||||
|
|
||||||
|
ThemeData appTheme = ThemeData(
|
||||||
|
primaryColor: _blue,
|
||||||
|
accentColor: _blue,
|
||||||
|
);
|
110
lib/main.dart
110
lib/main.dart
@ -1,111 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
void main() => runApp(MyApp());
|
import 'openlp_remote_app.dart';
|
||||||
|
|
||||||
class MyApp extends StatelessWidget {
|
void main() => runApp(OpenLPRemoteApp());
|
||||||
// This widget is the root of your application.
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return MaterialApp(
|
|
||||||
title: 'Flutter Demo',
|
|
||||||
theme: ThemeData(
|
|
||||||
// This is the theme of your application.
|
|
||||||
//
|
|
||||||
// Try running your application with "flutter run". You'll see the
|
|
||||||
// application has a blue toolbar. Then, without quitting the app, try
|
|
||||||
// changing the primarySwatch below to Colors.green and then invoke
|
|
||||||
// "hot reload" (press "r" in the console where you ran "flutter run",
|
|
||||||
// or simply save your changes to "hot reload" in a Flutter IDE).
|
|
||||||
// Notice that the counter didn't reset back to zero; the application
|
|
||||||
// is not restarted.
|
|
||||||
primarySwatch: Colors.blue,
|
|
||||||
),
|
|
||||||
home: MyHomePage(title: 'Flutter Demo Home Page'),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class MyHomePage extends StatefulWidget {
|
|
||||||
MyHomePage({Key key, this.title}) : super(key: key);
|
|
||||||
|
|
||||||
// This widget is the home page of your application. It is stateful, meaning
|
|
||||||
// that it has a State object (defined below) that contains fields that affect
|
|
||||||
// how it looks.
|
|
||||||
|
|
||||||
// This class is the configuration for the state. It holds the values (in this
|
|
||||||
// case the title) provided by the parent (in this case the App widget) and
|
|
||||||
// used by the build method of the State. Fields in a Widget subclass are
|
|
||||||
// always marked "final".
|
|
||||||
|
|
||||||
final String title;
|
|
||||||
|
|
||||||
@override
|
|
||||||
_MyHomePageState createState() => _MyHomePageState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _MyHomePageState extends State<MyHomePage> {
|
|
||||||
int _counter = 0;
|
|
||||||
|
|
||||||
void _incrementCounter() {
|
|
||||||
setState(() {
|
|
||||||
// This call to setState tells the Flutter framework that something has
|
|
||||||
// changed in this State, which causes it to rerun the build method below
|
|
||||||
// so that the display can reflect the updated values. If we changed
|
|
||||||
// _counter without calling setState(), then the build method would not be
|
|
||||||
// called again, and so nothing would appear to happen.
|
|
||||||
_counter++;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
// This method is rerun every time setState is called, for instance as done
|
|
||||||
// by the _incrementCounter method above.
|
|
||||||
//
|
|
||||||
// The Flutter framework has been optimized to make rerunning build methods
|
|
||||||
// fast, so that you can just rebuild anything that needs updating rather
|
|
||||||
// than having to individually change instances of widgets.
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
// Here we take the value from the MyHomePage object that was created by
|
|
||||||
// the App.build method, and use it to set our appbar title.
|
|
||||||
title: Text(widget.title),
|
|
||||||
),
|
|
||||||
body: Center(
|
|
||||||
// Center is a layout widget. It takes a single child and positions it
|
|
||||||
// in the middle of the parent.
|
|
||||||
child: Column(
|
|
||||||
// Column is also layout widget. It takes a list of children and
|
|
||||||
// arranges them vertically. By default, it sizes itself to fit its
|
|
||||||
// children horizontally, and tries to be as tall as its parent.
|
|
||||||
//
|
|
||||||
// Invoke "debug painting" (press "p" in the console, choose the
|
|
||||||
// "Toggle Debug Paint" action from the Flutter Inspector in Android
|
|
||||||
// Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
|
|
||||||
// to see the wireframe for each widget.
|
|
||||||
//
|
|
||||||
// Column has various properties to control how it sizes itself and
|
|
||||||
// how it positions its children. Here we use mainAxisAlignment to
|
|
||||||
// center the children vertically; the main axis here is the vertical
|
|
||||||
// axis because Columns are vertical (the cross axis would be
|
|
||||||
// horizontal).
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: <Widget>[
|
|
||||||
Text(
|
|
||||||
'You have pushed the button this many times:',
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
'$_counter',
|
|
||||||
style: Theme.of(context).textTheme.display1,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
floatingActionButton: FloatingActionButton(
|
|
||||||
onPressed: _incrementCounter,
|
|
||||||
tooltip: 'Increment',
|
|
||||||
child: Icon(Icons.add),
|
|
||||||
), // This trailing comma makes auto-formatting nicer for build methods.
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
62
lib/openlp_remote_app.dart
Normal file
62
lib/openlp_remote_app.dart
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'app_theme.dart';
|
||||||
|
|
||||||
|
import 'widgets/bottom_navigation_bar.dart';
|
||||||
|
import 'widgets/search_floating_button.dart';
|
||||||
|
|
||||||
|
class OpenLPRemoteApp extends StatefulWidget {
|
||||||
|
@override
|
||||||
|
_OpenLPRemoteAppState createState() => _OpenLPRemoteAppState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _OpenLPRemoteAppState extends State<OpenLPRemoteApp>
|
||||||
|
with SingleTickerProviderStateMixin {
|
||||||
|
TabController tabController;
|
||||||
|
SearchFloatingButton searchActionButton;
|
||||||
|
int tabBarIndex;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
tabBarIndex = 0;
|
||||||
|
tabController =
|
||||||
|
TabController(length: 2, vsync: this, initialIndex: tabBarIndex);
|
||||||
|
searchActionButton = SearchFloatingButton();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return MaterialApp(
|
||||||
|
debugShowCheckedModeBanner: false,
|
||||||
|
theme: appTheme,
|
||||||
|
home: Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: Text('OpenLP Remote'),
|
||||||
|
actions: <Widget>[
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(Icons.settings),
|
||||||
|
onPressed: () {},
|
||||||
|
tooltip: 'Settings',
|
||||||
|
),
|
||||||
|
],
|
||||||
|
bottom: TabBar(
|
||||||
|
tabs: <Widget>[
|
||||||
|
Tab(text: 'SERVICE'),
|
||||||
|
Tab(text: 'SLIDES'),
|
||||||
|
],
|
||||||
|
controller: tabController,
|
||||||
|
onTap: (index) {
|
||||||
|
setState(() {
|
||||||
|
tabBarIndex = index;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
floatingActionButton: searchActionButton,
|
||||||
|
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
|
||||||
|
bottomNavigationBar: AppBottomNavigationBar(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
0
lib/screens/service_screen.dart
Normal file
0
lib/screens/service_screen.dart
Normal file
0
lib/screens/slides_screen.dart
Normal file
0
lib/screens/slides_screen.dart
Normal file
44
lib/widgets/bottom_navigation_bar.dart
Normal file
44
lib/widgets/bottom_navigation_bar.dart
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:openlp_remote/widgets/show_alert_dialog.dart';
|
||||||
|
|
||||||
|
import 'display_options_bottom_sheet.dart';
|
||||||
|
|
||||||
|
class _Action {
|
||||||
|
IconData icon;
|
||||||
|
String title;
|
||||||
|
VoidCallback callback;
|
||||||
|
_Action(this.icon, this.title, this.callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
class AppBottomNavigationBar extends StatelessWidget {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final List<_Action> _actions = [
|
||||||
|
_Action(Icons.add_alert, 'Alert', () {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => ShowAlertDialog(),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
_Action(Icons.personal_video, 'Display', () {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => DisplayOptionsDialog(),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
];
|
||||||
|
return BottomAppBar(
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: _actions
|
||||||
|
.map((action) => IconButton(
|
||||||
|
icon: Icon(action.icon),
|
||||||
|
onPressed: action.callback,
|
||||||
|
tooltip: action.title,
|
||||||
|
color: Theme.of(context).accentColor,
|
||||||
|
))
|
||||||
|
.toList(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
41
lib/widgets/display_options_bottom_sheet.dart
Normal file
41
lib/widgets/display_options_bottom_sheet.dart
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class _Action {
|
||||||
|
String title;
|
||||||
|
VoidCallback callback;
|
||||||
|
_Action(this.title, this.callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
class DisplayOptionsDialog extends StatelessWidget {
|
||||||
|
final List<_Action> _actions = [
|
||||||
|
_Action('Blank', () {
|
||||||
|
print('Blank screen');
|
||||||
|
}),
|
||||||
|
_Action('Theme', () {
|
||||||
|
print('Theme screen');
|
||||||
|
}),
|
||||||
|
_Action('Desktop', () {
|
||||||
|
print('Desktop screen');
|
||||||
|
}),
|
||||||
|
_Action('Show', () {
|
||||||
|
print('Show screen');
|
||||||
|
}),
|
||||||
|
];
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return SimpleDialog(
|
||||||
|
contentPadding: EdgeInsets.all(20.0),
|
||||||
|
children: _actions
|
||||||
|
.map((action) => OutlineButton(
|
||||||
|
color: Colors.red,
|
||||||
|
child: Text(action.title),
|
||||||
|
onPressed: () {
|
||||||
|
action.callback();
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
))
|
||||||
|
.toList(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
19
lib/widgets/search_floating_button.dart
Normal file
19
lib/widgets/search_floating_button.dart
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../widgets/service_item_bottom_sheet.dart';
|
||||||
|
|
||||||
|
class SearchFloatingButton extends StatelessWidget {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return FloatingActionButton.extended(
|
||||||
|
label: Text('New service item'),
|
||||||
|
icon: Icon(Icons.search),
|
||||||
|
onPressed: () {
|
||||||
|
showModalBottomSheet<void>(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => ServiceItemBottomSheet(),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
31
lib/widgets/service_item_bottom_sheet.dart
Normal file
31
lib/widgets/service_item_bottom_sheet.dart
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class _ServiceItem {
|
||||||
|
IconData icon;
|
||||||
|
String title;
|
||||||
|
_ServiceItem({this.icon, this.title});
|
||||||
|
}
|
||||||
|
|
||||||
|
class ServiceItemBottomSheet extends StatelessWidget {
|
||||||
|
final List<_ServiceItem> _serviceItems = [
|
||||||
|
_ServiceItem(icon: Icons.audiotrack, title: 'Songs'),
|
||||||
|
_ServiceItem(icon: Icons.book, title: 'Bibles'),
|
||||||
|
_ServiceItem(icon: Icons.present_to_all, title: 'Presentations'),
|
||||||
|
_ServiceItem(icon: Icons.image, title: 'Images'),
|
||||||
|
_ServiceItem(icon: Icons.ondemand_video, title: 'Medias'),
|
||||||
|
];
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Wrap(
|
||||||
|
children: _serviceItems.map((item) {
|
||||||
|
return ListTile(
|
||||||
|
leading: Icon(item.icon),
|
||||||
|
title: Text(item.title),
|
||||||
|
onTap: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
30
lib/widgets/show_alert_dialog.dart
Normal file
30
lib/widgets/show_alert_dialog.dart
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class ShowAlertDialog extends StatelessWidget {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
actions: <Widget>[
|
||||||
|
FlatButton(
|
||||||
|
child: Text('Cancel'),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
FlatButton(
|
||||||
|
child: Text('Show'),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
|
content: TextField(
|
||||||
|
maxLines: 5,
|
||||||
|
autofocus: true,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
border: OutlineInputBorder(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -1,30 +0,0 @@
|
|||||||
// This is a basic Flutter widget test.
|
|
||||||
//
|
|
||||||
// To perform an interaction with a widget in your test, use the WidgetTester
|
|
||||||
// utility that Flutter provides. For example, you can send tap and scroll
|
|
||||||
// gestures. You can also use WidgetTester to find child widgets in the widget
|
|
||||||
// tree, read text, and verify that the values of widget properties are correct.
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
|
||||||
|
|
||||||
import 'package:openlp_remote/main.dart';
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
|
|
||||||
// Build our app and trigger a frame.
|
|
||||||
await tester.pumpWidget(MyApp());
|
|
||||||
|
|
||||||
// Verify that our counter starts at 0.
|
|
||||||
expect(find.text('0'), findsOneWidget);
|
|
||||||
expect(find.text('1'), findsNothing);
|
|
||||||
|
|
||||||
// Tap the '+' icon and trigger a frame.
|
|
||||||
await tester.tap(find.byIcon(Icons.add));
|
|
||||||
await tester.pump();
|
|
||||||
|
|
||||||
// Verify that our counter has incremented.
|
|
||||||
expect(find.text('0'), findsNothing);
|
|
||||||
expect(find.text('1'), findsOneWidget);
|
|
||||||
});
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user