diff --git a/lib/app_theme.dart b/lib/app_theme.dart new file mode 100644 index 0000000..8e3117b --- /dev/null +++ b/lib/app_theme.dart @@ -0,0 +1,8 @@ +import 'package:flutter/material.dart'; + +Color _blue = Color(0xFF3D6ABD); + +ThemeData appTheme = ThemeData( + primaryColor: _blue, + accentColor: _blue, +); diff --git a/lib/main.dart b/lib/main.dart index f4ebf1d..1c50126 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,111 +1,5 @@ import 'package:flutter/material.dart'; -void main() => runApp(MyApp()); +import 'openlp_remote_app.dart'; -class MyApp extends StatelessWidget { - // 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 { - 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: [ - 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. - ); - } -} +void main() => runApp(OpenLPRemoteApp()); diff --git a/lib/openlp_remote_app.dart b/lib/openlp_remote_app.dart new file mode 100644 index 0000000..31034c4 --- /dev/null +++ b/lib/openlp_remote_app.dart @@ -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 + 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: [ + IconButton( + icon: Icon(Icons.settings), + onPressed: () {}, + tooltip: 'Settings', + ), + ], + bottom: TabBar( + tabs: [ + Tab(text: 'SERVICE'), + Tab(text: 'SLIDES'), + ], + controller: tabController, + onTap: (index) { + setState(() { + tabBarIndex = index; + }); + }, + ), + ), + floatingActionButton: searchActionButton, + floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, + bottomNavigationBar: AppBottomNavigationBar(), + ), + ); + } +} diff --git a/lib/screens/service_screen.dart b/lib/screens/service_screen.dart new file mode 100644 index 0000000..e69de29 diff --git a/lib/screens/slides_screen.dart b/lib/screens/slides_screen.dart new file mode 100644 index 0000000..e69de29 diff --git a/lib/widgets/bottom_navigation_bar.dart b/lib/widgets/bottom_navigation_bar.dart new file mode 100644 index 0000000..d3ea6b4 --- /dev/null +++ b/lib/widgets/bottom_navigation_bar.dart @@ -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(), + ), + ); + } +} diff --git a/lib/widgets/display_options_bottom_sheet.dart b/lib/widgets/display_options_bottom_sheet.dart new file mode 100644 index 0000000..bb93fb4 --- /dev/null +++ b/lib/widgets/display_options_bottom_sheet.dart @@ -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(), + ); + } +} diff --git a/lib/widgets/search_floating_button.dart b/lib/widgets/search_floating_button.dart new file mode 100644 index 0000000..1fdd3da --- /dev/null +++ b/lib/widgets/search_floating_button.dart @@ -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( + context: context, + builder: (context) => ServiceItemBottomSheet(), + ); + }, + ); + } +} diff --git a/lib/widgets/service_item_bottom_sheet.dart b/lib/widgets/service_item_bottom_sheet.dart new file mode 100644 index 0000000..262e48e --- /dev/null +++ b/lib/widgets/service_item_bottom_sheet.dart @@ -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(), + ); + } +} diff --git a/lib/widgets/show_alert_dialog.dart b/lib/widgets/show_alert_dialog.dart new file mode 100644 index 0000000..ce23201 --- /dev/null +++ b/lib/widgets/show_alert_dialog.dart @@ -0,0 +1,30 @@ +import 'package:flutter/material.dart'; + +class ShowAlertDialog extends StatelessWidget { + @override + Widget build(BuildContext context) { + return AlertDialog( + actions: [ + 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(), + ), + ), + ); + } +} diff --git a/test/widget_test.dart b/test/widget_test.dart deleted file mode 100644 index 990b69e..0000000 --- a/test/widget_test.dart +++ /dev/null @@ -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); - }); -}