| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 import 'package:sky/theme/colors.dart' as colors; | 5 import 'package:sky/theme/colors.dart' as colors; |
| 6 import 'package:sky/widgets/basic.dart'; | 6 import 'package:sky/widgets/basic.dart'; |
| 7 import 'package:sky/widgets/navigator.dart'; | 7 import 'package:sky/widgets/navigator.dart'; |
| 8 import 'package:sky/widgets/theme.dart'; | 8 import 'package:sky/widgets/theme.dart'; |
| 9 import 'package:sky/widgets/widget.dart'; | 9 import 'package:sky/widgets/widget.dart'; |
| 10 | 10 |
| 11 import 'measurement.dart'; | 11 import 'measurement.dart'; |
| 12 import 'home.dart'; | 12 import 'home.dart'; |
| 13 import 'settings.dart'; | 13 import 'settings.dart'; |
| 14 import 'fitness_types.dart'; | 14 import 'fitness_types.dart'; |
| 15 | 15 |
| 16 class FitnessApp extends App { | 16 class FitnessApp extends App { |
| 17 | 17 |
| 18 NavigationState _navigationState; | 18 NavigationState _navigationState; |
| 19 FitnessApp() { | 19 FitnessApp() { |
| 20 _navigationState = new NavigationState([ | 20 _navigationState = new NavigationState([ |
| 21 new Route( | 21 new Route( |
| 22 name: '/', | 22 name: '/', |
| 23 builder: (navigator, route) => new HomeFragment(navigator, _userData) | 23 builder: (navigator, route) => new HomeFragment(navigator, _userData) |
| 24 ), | 24 ), |
| 25 new Route( | 25 new Route( |
| 26 name: '/settings', | 26 name: '/settings', |
| 27 builder: (navigator, route) => new SettingsFragment(navigator, backupSet
ting, settingsUpdater) | 27 builder: (navigator, route) => new SettingsFragment(navigator, backupSet
ting, settingsUpdater) |
| 28 ), | 28 ), |
| 29 ]); | 29 ]); |
| 30 } | 30 } |
| 31 | 31 |
| 32 @override |
| 32 void onBack() { | 33 void onBack() { |
| 33 if (_navigationState.hasPrevious()) { | 34 if (_navigationState.hasPrevious()) { |
| 34 setState(() { | 35 setState(() { |
| 35 _navigationState.pop(); | 36 _navigationState.pop(); |
| 36 }); | 37 }); |
| 37 } else { | 38 } else { |
| 38 super.onBack(); | 39 super.onBack(); |
| 39 } | 40 } |
| 40 } | 41 } |
| 41 | 42 |
| 42 BackupMode backupSetting = BackupMode.disabled; | 43 BackupMode backupSetting = BackupMode.disabled; |
| 43 | 44 |
| 44 void settingsUpdater({ BackupMode backup }) { | 45 void settingsUpdater({ BackupMode backup }) { |
| 45 setState(() { | 46 setState(() { |
| 46 if (backup != null) | 47 if (backup != null) |
| 47 backupSetting = backup; | 48 backupSetting = backup; |
| 48 }); | 49 }); |
| 49 } | 50 } |
| 50 | 51 |
| 51 final List<Measurement> _userData = [ | 52 final List<Measurement> _userData = [ |
| 52 new Measurement(when: new DateTime.now(), weight: 400.0) | 53 new Measurement(when: new DateTime.now(), weight: 400.0) |
| 53 ]; | 54 ]; |
| 54 | 55 |
| 56 @override |
| 55 Widget build() { | 57 Widget build() { |
| 56 return new Theme( | 58 return new Theme( |
| 57 data: new ThemeData( | 59 data: new ThemeData( |
| 58 brightness: ThemeBrightness.light, | 60 brightness: ThemeBrightness.light, |
| 59 primarySwatch: colors.Indigo, | 61 primarySwatch: colors.Indigo, |
| 60 accentColor: colors.PinkAccent[200] | 62 accentColor: colors.PinkAccent[200] |
| 61 ), | 63 ), |
| 62 child: new Navigator(_navigationState) | 64 child: new Navigator(_navigationState) |
| 63 ); | 65 ); |
| 64 } | 66 } |
| 65 } | 67 } |
| 66 | 68 |
| 67 void main() { | 69 void main() { |
| 68 runApp(new FitnessApp()); | 70 runApp(new FitnessApp()); |
| 69 } | 71 } |
| OLD | NEW |