Bläddra i källkod

Added scaffolding for web platform; removed dependency on dart:io to fix compilation issue for web

Anatoly Pulyaevskiy 5 år sedan
förälder
incheckning
c8530d55d5

+ 7
- 0
packages/zefyr/example/android/app/src/debug/AndroidManifest.xml Visa fil

@@ -0,0 +1,7 @@
1
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+    package="com.zefyr.example">
3
+    <!-- Flutter needs it to communicate with the running application
4
+         to allow setting breakpoints, to provide hot reload, etc.
5
+    -->
6
+    <uses-permission android:name="android.permission.INTERNET"/>
7
+</manifest>

+ 13
- 0
packages/zefyr/example/android/app/src/main/kotlin/com/zefyr/example/MainActivity.kt Visa fil

@@ -0,0 +1,13 @@
1
+package com.zefyr.example
2
+
3
+import android.os.Bundle
4
+
5
+import io.flutter.app.FlutterActivity
6
+import io.flutter.plugins.GeneratedPluginRegistrant
7
+
8
+class MainActivity: FlutterActivity() {
9
+  override fun onCreate(savedInstanceState: Bundle?) {
10
+    super.onCreate(savedInstanceState)
11
+    GeneratedPluginRegistrant.registerWith(this)
12
+  }
13
+}

+ 7
- 0
packages/zefyr/example/android/app/src/profile/AndroidManifest.xml Visa fil

@@ -0,0 +1,7 @@
1
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+    package="com.zefyr.example">
3
+    <!-- Flutter needs it to communicate with the running application
4
+         to allow setting breakpoints, to provide hot reload, etc.
5
+    -->
6
+    <uses-permission android:name="android.permission.INTERNET"/>
7
+</manifest>

+ 11
- 0
packages/zefyr/example/ios/Flutter/flutter_export_environment.sh Visa fil

@@ -0,0 +1,11 @@
1
+#!/bin/sh
2
+# This is a generated file; do not edit or check into version control.
3
+export "FLUTTER_ROOT=/Users/anatoly/Projects/flutter"
4
+export "FLUTTER_APPLICATION_PATH=/Users/anatoly/Projects/zefyr/packages/zefyr/example"
5
+export "FLUTTER_TARGET=/Users/anatoly/Projects/zefyr/packages/zefyr/example/lib/main.dart"
6
+export "FLUTTER_BUILD_DIR=build"
7
+export "SYMROOT=${SOURCE_ROOT}/../build/ios"
8
+export "FLUTTER_FRAMEWORK_DIR=/Users/anatoly/Projects/flutter/bin/cache/artifacts/engine/ios"
9
+export "FLUTTER_BUILD_NAME=1.0.0"
10
+export "FLUTTER_BUILD_NUMBER=1"
11
+export "TRACK_WIDGET_CREATION=true"

+ 1
- 1
packages/zefyr/example/ios/Podfile.lock Visa fil

@@ -19,7 +19,7 @@ EXTERNAL SOURCES:
19 19
     :path: ".symlinks/plugins/url_launcher/ios"
20 20
 
21 21
 SPEC CHECKSUMS:
22
-  Flutter: 58dd7d1b27887414a370fcccb9e645c08ffd7a6a
22
+  Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
23 23
   image_picker: 16e5fec1fbc87fd3b297c53e4048521eaf17cd06
24 24
   url_launcher: 0067ddb8f10d36786672aa0722a21717dba3a298
25 25
 

+ 13
- 0
packages/zefyr/example/ios/Runner/AppDelegate.swift Visa fil

@@ -0,0 +1,13 @@
1
+import UIKit
2
+import Flutter
3
+
4
+@UIApplicationMain
5
+@objc class AppDelegate: FlutterAppDelegate {
6
+  override func application(
7
+    _ application: UIApplication,
8
+    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
9
+  ) -> Bool {
10
+    GeneratedPluginRegistrant.register(with: self)
11
+    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
12
+  }
13
+}

+ 1
- 0
packages/zefyr/example/ios/Runner/Runner-Bridging-Header.h Visa fil

@@ -0,0 +1 @@
1
+#import "GeneratedPluginRegistrant.h"

+ 10
- 0
packages/zefyr/example/web/index.html Visa fil

@@ -0,0 +1,10 @@
1
+<!DOCTYPE html>
2
+<html>
3
+<head>
4
+  <meta charset="UTF-8">
5
+  <title>example</title>
6
+</head>
7
+<body>
8
+  <script src="main.dart.js" type="application/javascript"></script>
9
+</body>
10
+</html>

+ 15
- 4
packages/zefyr/lib/src/widgets/theme.dart Visa fil

@@ -1,7 +1,6 @@
1 1
 // Copyright (c) 2018, the Zefyr project authors.  Please see the AUTHORS file
2 2
 // for details. All rights reserved. Use of this source code is governed by a
3 3
 // BSD-style license that can be found in the LICENSE file.
4
-import 'dart:io';
5 4
 
6 5
 import 'package:flutter/material.dart';
7 6
 import 'package:flutter/widgets.dart';
@@ -67,6 +66,7 @@ class ZefyrThemeData {
67 66
   final ZefyrToolbarTheme toolbarTheme;
68 67
 
69 68
   factory ZefyrThemeData.fallback(BuildContext context) {
69
+    final ThemeData themeData = Theme.of(context);
70 70
     final defaultStyle = DefaultTextStyle.of(context);
71 71
     final paragraphStyle = defaultStyle.style.copyWith(
72 72
       fontSize: 16.0,
@@ -87,7 +87,7 @@ class ZefyrThemeData {
87 87
       paragraphTheme:
88 88
           new StyleTheme(textStyle: paragraphStyle, padding: padding),
89 89
       headingTheme: new HeadingTheme.fallback(),
90
-      blockTheme: new BlockTheme.fallback(),
90
+      blockTheme: new BlockTheme.fallback(themeData),
91 91
       selectionColor: Colors.lightBlueAccent.shade100,
92 92
       cursorColor: Colors.black,
93 93
       indentSize: 16.0,
@@ -224,8 +224,19 @@ class BlockTheme {
224 224
   });
225 225
 
226 226
   /// Creates fallback theme for blocks.
227
-  factory BlockTheme.fallback() {
227
+  factory BlockTheme.fallback(ThemeData themeData) {
228 228
     final padding = const EdgeInsets.only(bottom: 8.0);
229
+    String fontFamily;
230
+    switch (themeData.platform) {
231
+      case TargetPlatform.iOS:
232
+        fontFamily = 'Menlo';
233
+        break;
234
+      case TargetPlatform.android:
235
+      case TargetPlatform.fuchsia:
236
+        fontFamily = 'Roboto Mono';
237
+        break;
238
+    }
239
+
229 240
     return new BlockTheme(
230 241
       bulletList: new StyleTheme(padding: padding),
231 242
       numberList: new StyleTheme(padding: padding),
@@ -236,7 +247,7 @@ class BlockTheme {
236 247
       code: new StyleTheme(
237 248
         textStyle: new TextStyle(
238 249
           color: Colors.blueGrey.shade800,
239
-          fontFamily: Platform.isIOS ? 'Menlo' : 'Roboto Mono',
250
+          fontFamily: fontFamily,
240 251
           fontSize: 14.0,
241 252
           height: 1.25,
242 253
         ),