Skip to content

Commit

Permalink
device preview
Browse files Browse the repository at this point in the history
  • Loading branch information
omergamliel3 committed Sep 18, 2020
1 parent 85a1e13 commit 787328a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 59 deletions.
24 changes: 11 additions & 13 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

import 'package:flutter/services.dart' as services;
import 'package:flutter/foundation.dart' as foundation;
import 'package:scoped_model/scoped_model.dart';
import 'package:device_preview/device_preview.dart';
import 'package:page_transition/page_transition.dart';

import 'package:MyNews/scoped-models/main.dart';
Expand All @@ -19,7 +20,8 @@ import 'package:MyNews/shared/global_values.dart';

void main() {
// Main Function
runApp(MyApp());
runApp(DevicePreview(
enabled: !foundation.kReleaseMode, builder: (context) => MyApp()));
}

class MyApp extends StatefulWidget {
Expand All @@ -35,8 +37,10 @@ class _MyAppState extends State<MyApp> {
// Called when this object is inserted into the tree.
@override
void initState() {
SystemChrome.setPreferredOrientations(
[DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]);
services.SystemChrome.setPreferredOrientations([
services.DeviceOrientation.portraitUp,
services.DeviceOrientation.portraitDown
]);
// init theme data
future = _model.initThemeData();
super.initState();
Expand Down Expand Up @@ -119,36 +123,30 @@ class _MyAppState extends State<MyApp> {
);
}

// This widget is the root of the application.
@override
Widget build(BuildContext context) {
// builds the application after the future completes
return FutureBuilder<void>(
future: future,
builder: (BuildContext context, AsyncSnapshot<void> snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
// if async has error display error text widget
if (snapshot.hasError) {
_handleSnapshotError(snapshot);
}
// return the MeterialApp wraps with scoped model widget
return ScopedModel<MainModel>(
// the scoped model instance attached to the app widget
model: _model,
child: MaterialApp(
title: appName,
locale: DevicePreview.of(context).locale,
builder: DevicePreview.appBuilder,
theme: getAndroidThemeData(_model.selectedAccentColorIndex),
darkTheme: darkThemeData(_model.selectedAccentColorIndex),
// themeMode according to the _model.isDark value
themeMode: _model.isDark ? ThemeMode.dark : ThemeMode.light,
// routes
routes: {
'/': (BuildContext context) => LoadingScreen(_model),
'/main': (BuildContext context) =>
MainPage(_model, changeState)
},
onGenerateRoute: _routes,
// On Unknown Route / Routes error
onUnknownRoute: _unknownRoute,
debugShowCheckedModeBanner: false,
));
Expand Down
63 changes: 17 additions & 46 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
name: MyNews
description: News App

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1

environment:
sdk: ">=2.6.0 <3.0.0"

dependencies:

flutter:
sdk: flutter

# state managment
scoped_model: ^1.0.1
# newtork
http: ^0.12.0+2

# local storage
shared_preferences: ^0.5.6+2
url_launcher: ^5.4.2
share: ^0.6.3+1
sqflite: ^1.3.0
path_provider: ^1.6.9
# page transition animations
page_transition: ^1.1.5
# location
geolocator: ^5.3.1
# device
url_launcher: ^5.4.2
android_intent: ^0.3.7+2
share: ^0.6.3+1
flutter_email_sender: ^3.0.1
fluttertoast: ^4.0.1
# native plugins
flutter_native_splash: ^0.1.9
flutter_webview_plugin: ^0.3.11
flutter_local_notifications: ^1.4.3
# firebase
firebase_admob: ^0.9.3+2
admob_flutter: ^0.3.4
flutter_email_sender: ^3.0.1
path_provider: ^1.6.9
fluttertoast: ^4.0.1
sqflite: ^1.3.0
# helpers
timeago: ^2.0.26
device_preview: ^0.4.8

dev_dependencies:
flutter_test:
Expand All @@ -56,49 +56,20 @@ flutter_native_splash:
color: "#ffffff"
android_disable_fullscreen: true

# flutter pub run flutter_launcher_icons:main
# flutter pub pub run flutter_native_splash:create

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter.
flutter:

# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true

# To add assets to your application, add an assets section, like this:
assets:
- Assets/images/placeHolder.jpg
- Assets/images/loading.jpg
- Assets/images/app-icon.png
- Assets/images/loading_screen_logo.png
- Assets/images/splash-logo.png

# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.

# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages

# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
fonts:
- family: Roboto
fonts:
- asset: Assets/Fonts/Roboto-Medium.ttf
weight: 700
# - family: Releway
# fonts:
# - asset: Assets/Fonts/Raleway-Regular.ttf

# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages


0 comments on commit 787328a

Please sign in to comment.