Started implementing flutter_platform_widgets
Signed-off-by: Andreas Fahrecker <AndreasFahrecker@gmail.com>
This commit is contained in:
parent
40bdcc44f9
commit
ed5d2b92f7
27
lib/app.dart
27
lib/app.dart
@ -1,10 +1,11 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
|
||||
import 'package:flutter_redux/flutter_redux.dart';
|
||||
import 'package:redux/redux.dart';
|
||||
import 'package:time_progress_tracker/models/app_state.dart';
|
||||
import 'package:time_progress_tracker/screens/progress_creation_screen.dart';
|
||||
import 'package:time_progress_tracker/screens/home_screen.dart';
|
||||
import 'package:time_progress_tracker/screens/progress_detail_screen.dart';
|
||||
import 'package:time_progress_tracker/screens/dashboard_screen.dart';
|
||||
import 'package:time_progress_tracker/utils/color_utils.dart';
|
||||
|
||||
class TimeProgressTrackerApp extends StatelessWidget {
|
||||
static const String name = "Time Progress Tracker";
|
||||
@ -20,23 +21,11 @@ class TimeProgressTrackerApp extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return StoreProvider(
|
||||
store: store,
|
||||
child: MaterialApp(
|
||||
child: PlatformApp(
|
||||
title: name,
|
||||
theme: ThemeData(
|
||||
primarySwatch: Colors.indigo,
|
||||
accentColor: Colors.indigoAccent,
|
||||
brightness: Brightness.light,
|
||||
visualDensity: VisualDensity.adaptivePlatformDensity,
|
||||
),
|
||||
initialRoute: HomeScreen.routeName,
|
||||
routes: {
|
||||
HomeScreen.routeName: (BuildContext context) =>
|
||||
HomeScreen(),
|
||||
ProgressDetailScreen.routeName: (BuildContext context) =>
|
||||
ProgressDetailScreen(),
|
||||
ProgressCreationScreen.routeName: (BuildContext context) =>
|
||||
ProgressCreationScreen(),
|
||||
},
|
||||
home: DashboardScreen(),
|
||||
material: (_, __) => MaterialAppData(theme: materialThemeData),
|
||||
cupertino: (_, __) => CupertinoAppData(theme: cupertinoThemeData),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
82
lib/screens/dashboard_screen.dart
Normal file
82
lib/screens/dashboard_screen.dart
Normal file
@ -0,0 +1,82 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
|
||||
import 'package:time_progress_tracker/utils/color_utils.dart';
|
||||
import 'package:time_progress_tracker/widgets/home/tabs/home_active_progresses_tab.dart';
|
||||
import 'package:time_progress_tracker/widgets/home/tabs/home_inactive_progresses_tab.dart';
|
||||
import 'package:time_progress_tracker/widgets/home/tabs/home_settings_tab.dart';
|
||||
|
||||
class DashboardScreen extends StatefulWidget {
|
||||
@override
|
||||
State<StatefulWidget> createState() => _DashboardScreenState();
|
||||
}
|
||||
|
||||
class _DashboardScreenState extends State<DashboardScreen> {
|
||||
int _tabSelectedIndex = 0;
|
||||
String title = "Active Progresses";
|
||||
|
||||
Widget _renderTabScreen(int tabIndex) {
|
||||
switch (tabIndex) {
|
||||
case 1:
|
||||
return HomeInactiveProgressesTab();
|
||||
case 2:
|
||||
return HomeSettingsTab();
|
||||
default:
|
||||
return HomeActiveProgressesTab();
|
||||
}
|
||||
}
|
||||
|
||||
String getScreenTitle(int tabIndex) {
|
||||
switch (tabIndex) {
|
||||
case 1:
|
||||
return "Inactive Progresses";
|
||||
case 2:
|
||||
return "Settings";
|
||||
default:
|
||||
return "ActiveProgresses";
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return PlatformScaffold(
|
||||
appBar: PlatformAppBar(
|
||||
title: Text(
|
||||
title,
|
||||
style: toolbarTextStyle,
|
||||
),
|
||||
cupertino: (_, __) => CupertinoNavigationBarData(
|
||||
transitionBetweenRoutes: false,
|
||||
),
|
||||
),
|
||||
material: (_, __) => MaterialScaffoldData(),
|
||||
body: _renderTabScreen(_tabSelectedIndex),
|
||||
bottomNavBar: PlatformNavBar(
|
||||
currentIndex: _tabSelectedIndex,
|
||||
itemChanged: (index) {
|
||||
setState(() {
|
||||
_tabSelectedIndex = index;
|
||||
title = getScreenTitle(index);
|
||||
});
|
||||
},
|
||||
backgroundColor: bottomTabsBackground,
|
||||
items: [
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.alarm, color: Colors.grey),
|
||||
label: "Active Progresses",
|
||||
activeIcon: Icon(Icons.alarm, color: Colors.white),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.alarm_off, color: Colors.grey),
|
||||
label: "Inactive Progresses",
|
||||
activeIcon: Icon(Icons.alarm_off, color: Colors.white),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.settings, color: Colors.grey),
|
||||
label: "Settings",
|
||||
activeIcon: Icon(Icons.settings, color: Colors.white),
|
||||
)
|
||||
]),
|
||||
);
|
||||
}
|
||||
}
|
20
lib/utils/color_utils.dart
Normal file
20
lib/utils/color_utils.dart
Normal file
@ -0,0 +1,20 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
final ThemeData materialThemeData = ThemeData(
|
||||
primarySwatch: Colors.indigo,
|
||||
scaffoldBackgroundColor: Colors.white,
|
||||
accentColor: Colors.indigo,
|
||||
appBarTheme: AppBarTheme(color: Colors.indigo.shade600),
|
||||
primaryColor: Colors.indigo,
|
||||
secondaryHeaderColor: Colors.indigo,
|
||||
canvasColor: Colors.indigo,
|
||||
backgroundColor: Colors.red,
|
||||
);
|
||||
final CupertinoThemeData cupertinoThemeData = CupertinoThemeData(
|
||||
primaryColor: Colors.indigo,
|
||||
barBackgroundColor: Colors.indigo,
|
||||
scaffoldBackgroundColor: Colors.white,
|
||||
);
|
||||
final toolbarTextStyle = TextStyle(color: Colors.white, fontSize: 16);
|
||||
final bottomTabsBackground = Colors.indigoAccent;
|
@ -127,6 +127,13 @@ packages:
|
||||
url: "git://github.com/yangyxd/flutter_picker.git"
|
||||
source: git
|
||||
version: "1.1.5"
|
||||
flutter_platform_widgets:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_platform_widgets
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.80.0"
|
||||
flutter_redux:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -375,4 +382,4 @@ packages:
|
||||
version: "2.2.1"
|
||||
sdks:
|
||||
dart: ">=2.12.0-259.9.beta <3.0.0"
|
||||
flutter: ">=1.20.0"
|
||||
flutter: ">=1.20.4"
|
||||
|
@ -27,14 +27,11 @@ dependencies:
|
||||
flutter_redux:
|
||||
flutter_picker:
|
||||
git: git://github.com/yangyxd/flutter_picker.git
|
||||
flutter_platform_widgets:
|
||||
meta:
|
||||
percent_indicator:
|
||||
redux:
|
||||
shared_preferences:
|
||||
|
||||
|
||||
# The following adds the Cupertino Icons font to your application.
|
||||
# Use with the CupertinoIcons class for iOS style icons.
|
||||
cupertino_icons: ^0.1.3
|
||||
|
||||
dev_dependencies:
|
||||
|
Loading…
x
Reference in New Issue
Block a user