瀏覽代碼

Merge pull request #150 from 0nn0/spacing-on-side

Spacing on side
iou90 5 年之前
父節點
當前提交
acf518542a
No account linked to committer's email address
共有 4 個文件被更改,包括 178 次插入2 次删除
  1. 22
    1
      demo/App.js
  2. 3
    1
      demo/config.js
  3. 8
    0
      demo/ios/demo.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
  4. 145
    0
      demo/newsletter.js

+ 22
- 1
demo/App.js 查看文件

@@ -7,6 +7,8 @@ import {
7 7
   TouchableOpacity,
8 8
   Platform,
9 9
   Linking,
10
+  Dimensions,
11
+  View,
10 12
 } from 'react-native';
11 13
 
12 14
 import AutoHeightWebView from 'react-native-autoheight-webview';
@@ -104,6 +106,15 @@ const Explorer = () => {
104 106
   const [heightSize, setHeightSize] = useState({height: 0, width: 0});
105 107
   const [widthSize, setWidthSize] = useState({height: 0, width: 0});
106 108
 
109
+  // set spacing on left/right
110
+  const spacing = 30;
111
+
112
+  // calculate new width of *real* content
113
+  const screenWidth = Math.round(Dimensions.get('window').width) - 2 * spacing;
114
+  // For example on iPhone 8, screenWidth will be 315
115
+
116
+  // I temporarily hard-coded the width into the newsletter.js its viewport tag
117
+
107 118
   return (
108 119
     <ScrollView
109 120
       style={{
@@ -115,7 +126,17 @@ const Explorer = () => {
115 126
         alignItems: 'center',
116 127
       }}>
117 128
       <AutoHeightWebView
118
-        customStyle={heightStyle}
129
+        scalesPageToFit
130
+        scrollEnabled={false}
131
+        scrollEnabledWithZoomedin={true}
132
+        customStyle={`
133
+          ${heightStyle}
134
+          #rnahw-wrapper {
135
+            padding: 0 ${spacing}px;
136
+            width: ${screenWidth};
137
+            box-sizing: border-box;
138
+          }
139
+        `}
119 140
         onError={onError}
120 141
         onLoad={onHeightLoad}
121 142
         onLoadStart={onHeightLoadStart}

+ 3
- 1
demo/config.js 查看文件

@@ -1,8 +1,10 @@
1 1
 'use strict';
2 2
 
3
+import newsletter from "./newsletter";
4
+
3 5
 const autoHeightHtml0 = `<p style="font-weight: 400;font-style: normal;font-size: 21px;line-height: 1.58;letter-spacing: -.003em;"><a href="https://github.com/iou90/react-native-autoheight-webview">Tags</a> are great for describing the essence of your story in a single word or phrase, but stories are rarely about a single thing. <span style="background-color: transparent !important;background-image: linear-gradient(to bottom, rgba(146, 249, 190, 1), rgba(146, 249, 190, 1));">If I pen a story about moving across the country to start a new job in a car with my husband, two cats, a dog, and a tarantula, I wouldn't only tag the piece with "moving". I’d also use the <a href="http://x-squad.com">tags</a> "pets", "marriage", "career change", and "travel tips".</span></p>`;
4 6
 
5
-const autoHeightHtml1 = `Tags are great for describing the essence of your story in a single word or phrase, but stories are rarely about a single thing. If I pen a story about moving across the country to start a new job in a car with my husband, two cats, a dog, and a tarantula, I wouldn’t only tag the piece with "moving".`;
7
+const autoHeightHtml1 = newsletter; //`Tags are great for describing the essence of your story in a single word or phrase, but stories are rarely about a single thing. If I pen a story about moving across the country to start a new job in a car with my husband, two cats, a dog, and a tarantula, I wouldn’t only tag the piece with "moving".`;
6 8
 
7 9
 const style0 = `
8 10
     p {

+ 8
- 0
demo/ios/demo.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist 查看文件

@@ -0,0 +1,8 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+<plist version="1.0">
4
+<dict>
5
+	<key>IDEDidComputeMac32BitWarning</key>
6
+	<true/>
7
+</dict>
8
+</plist>

+ 145
- 0
demo/newsletter.js 查看文件

@@ -0,0 +1,145 @@
1
+export default `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
2
+<html>
3
+  <head>
4
+    <title>DB BAHN - Current information about your connection:</title>
5
+    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
6
+    <meta name="viewport" content="width=315">
7
+  </head>
8
+  <body style="background-color: rgb(206, 206, 206);margin: 0; width:100%;">
9
+    <div id="doc" style="font-family:Arial,sans-serif;font-size:12px;height:100%; min-width: 500px; max-width: 944px; background: #fff; margin: 0; color:#333333">
10
+      <table style="width: 100%;">
11
+        <tr style="height: 48px;">
12
+          <td style="vertical-align:bottom;padding-left:24px;">
13
+              &nbsp;
14
+          </td>
15
+          <td style="vertical-align:bottom;text-align: right;">
16
+            <img style="padding-right:16px;" src="http://www.bahn.de/wmedia/view/mdb/media/app/push-email/logo-db.gif" width="126" height="32" alt="DB Bahn" />
17
+          </td>
18
+        </tr>
19
+      </table>
20
+
21
+      <div style="padding:0;border:0;background-color:#f00;height:48px;">
22
+        <p style="padding-top:12px;">
23
+          <span style="color:#fff; font-weight:bold; font-size:16px;padding-left:24px;margin-top:12px;">Current information on your connection (order HFRXDK)</span>
24
+        </p>
25
+      </div>
26
+      <div style="overflow: hidden;">
27
+        <img src="http://www.bahn.de/wmedia/view/mdb/media/app/push-email/push_uhr1_944x70.jpg" />
28
+      </div>
29
+
30
+      <div style="padding-left: 24px;padding-top:16px;padding-right:24px;">
31
+        <div style="margin-bottom: 8px;font-weight:bold;">
32
+          Dear Mr Foo,
33
+        </div>
34
+
35
+        <div style="margin-bottom: 4px;">
36
+          There are some changes affecting the connection you booked.
37
+          <br/>
38
+          Please click on the red button to request the latest information:
39
+        </div>
40
+        <div style="margin-top:20px; margin-bottom: 20px;" class="button-inside">
41
+           <span><a style="text-decoration: none; color: #FFFFFF; cursor: pointer; font-weight: bold; letter-spacing: 1px;background: none repeat scroll 0 0 #FF0000;border: 1px solid #AF1818;padding:2px;" href="http://reiseauskunft.bahn.de/bin/query.exe/en?E=P&storeRecData=pushService&dbkanal_009=L01_S01_D001_KNL0011_pushm_LZ03&timestamp=1562346136&SS=8000036&ZS=8400285&T=201907051626&VH=T%248000036%248000086%24201907051626%24201907051747%24ICE++848%C2%A7T%248000086%248400058%24201907051827%24201907052028%24ICE++122%C2%A7T%248400058%248400285%24201907052034%24201907052049%24IC++2270"><span>Current information about your connection:</span></a></span>
42
+        </div>
43
+        <div style="margin-bottom:8px;font-weight:bold;">
44
+          Deviation calculated from the time the mail was sent at 19:02 o'clock:
45
+        </div>
46
+        <div style="margin-bottom:8px;">
47
+            You may not reach your connecting train in time
48
+        </div>
49
+        <div style="margin-bottom: 4px;">
50
+          All data are included without warranty, express or implied. Please note that the current traffic situation can change at any time.
51
+        </div>
52
+        <div style="margin-top: 28px;margin-bottom:4px;"><span style="font-weight:bold;">Booked connection</span></div>
53
+        <table style="font-family:Arial,sans-serif;font-size:12px;border-collapse: collapse;border-spacing: 0;">
54
+            <tr>
55
+                <th style="border-top: 1px solid #000; font-weight: bold; padding: 2px 12px 2px 4px;">Station/Stop</th>
56
+                <th style="border-top: 1px solid #000; font-weight: bold; padding: 2px 12px 2px 4px;">Date</th>
57
+                <th style="border-top: 1px solid #000; font-weight: bold; padding: 2px 12px 2px 4px;" colspan="2">Time</th>
58
+                <th style="border-top: 1px solid #000; font-weight: bold; padding: 2px 12px 2px 4px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
59
+            </tr>
60
+           <tr class="first">
61
+                <td style="padding: 2px 12px 2px 4px;border-top: 1px solid #000;">Bielefeld Hbf</td>
62
+                <td style="padding: 2px 12px 2px 4px;border-top: 1px solid #000;">05.07.2019</td>
63
+                <td style="padding: 2px 12px 2px 4px;border-top: 1px solid #000;">ab</td>
64
+                <td style="padding: 2px 12px 2px 4px;border-top: 1px solid #000;">16:26</td>
65
+                <td style="padding: 2px 12px 2px 4px;border-top: 1px solid #000;"><a style="text-decoration: underline; color:#333333;word-wrap:normal;" href="http://reiseauskunft.bahn.de/bin/query.exe/en?E=P&storeRecData=pushService&dbkanal_009=L01_S01_D001_KNL0011_pushm_LZ03&timestamp=1562346136&SS=8000036&ZS=8400285&T=201907051626&VH=T%248000036%248000086%24201907051626%24201907051747%24ICE++848%C2%A7T%248000086%248400058%24201907051827%24201907052028%24ICE++122%C2%A7T%248400058%248400285%24201907052034%24201907052049%24IC++2270"><span>Access current information</span></a></td>
66
+           </tr>
67
+           <tr class="last">
68
+                <td style="padding: 2px 12px 2px 4px;border-bottom: 1px solid #000;">Haarlem</td>
69
+                <td style="padding: 2px 12px 2px 4px;border-bottom: 1px solid #000;">05.07.2019</td>
70
+                <td style="padding: 2px 12px 2px 4px;border-bottom: 1px solid #000;">an</td>
71
+                <td style="padding: 2px 12px 2px 4px;border-bottom: 1px solid #000;">20:49</td>
72
+                <td style="padding: 2px 12px 2px 4px;border-bottom: 1px solid #000;">&nbsp;</td>
73
+           </tr>
74
+        </table>
75
+        <br/>
76
+
77
+        <div style="margin-top: 20px; margin-bottom: 4px;">
78
+          Kind regards,
79
+        </div>
80
+        <p>
81
+          <div style="overflow: hidden;">
82
+              <img title="Your Team from www.bahn.de" alt="Your Team from www.bahn.de" src="http://www.bahn.de/wmedia/view/mdb/media/app/push-email/unterschrift_pk_en.gif" />
83
+          </div>
84
+        </p>
85
+
86
+        <div style="margin-top:20px; margin-bottom:20px; border-color:#cccccc; border-width:1px 0 0 0; border-style:solid;"></div>
87
+
88
+        <p style="margin-bottom: 4px;">
89
+          <span style="font-weight:bold;">Additional information</span>
90
+        </p>
91
+
92
+        <p style="margin-bottom: 4px;">
93
+          <a style="color: #333333; text-decoration: underline;" href="http://www.bahn.de/app_tarifinfo_pk_en.shtml">Information on the validity of tickets and reservations</a>
94
+        </p>
95
+
96
+        <p style="margin-bottom: 4px;">
97
+          Current real-time information is not available for all modes of transportation. Possible portions of your itinerary by public transportation (e.g. by bus or tram) may therefore not be included in our information service.
98
+          <br/><br/>
99
+          Should your trip not be possible as planned (e.g. a missed connection due to a delay, or cancellation etc.), your passenger rights are still valid. These can be read at <a style="color: #333333;text-decoration: underline;" href="http://www.bahn.de/passengersrights">www.bahn.de/passengersrights</a>. 
100
+          <br/>
101
+        </p>
102
+
103
+        <p style="margin-bottom: 4px;">
104
+            All information on the delay alarm will be deleted at the end of the journey.
105
+        </p>
106
+        <p style="margin-bottom: 4px;margin-top: 20px;">
107
+          <a style="color: #333333; text-decoration: underline;" href="http://www.bahn.de/app_hilfe_pushnotification_pk_en_GBR.shtml">Push notification instead of e-mail</a>
108
+        </p>
109
+        <p style="margin-bottom: 4px;">
110
+          If you use the DB Navigator app, you can receive the delay alarm on your smart phone as a push notification instead of as an e-mail.
111
+        </p>
112
+        <p style="margin-bottom: 4px;">
113
+          <a style="color: #333333; text-decoration: underline;" href="http://www.bahn.de/app_hilfe_pushnotification_pk_en_GBR.shtml">How to activate push notifications</a>
114
+        </p>
115
+      </div>
116
+
117
+      <div style="margin-left:24px; margin-right:24px;margin-top:20px; margin-bottom:20px; border-color:#cccccc; border-width:1px 0 0 0; border-style:solid;"></div>
118
+      <div style="font-size:10px; padding-left: 24px;padding-right:24px;">
119
+        <p><span style="font-weight:bold;">Publishing details</span></p>
120
+        <p>
121
+          DB Vertrieb GmbH<br/>
122
+          Stephensonstraße 1<br/>
123
+          60326 Frankfurt am Main, Germany<br/>
124
+        </p>
125
+        <p>
126
+          German Register of Companies (Handelsregister) B for the Local Court of Frankfurt am Main<br/>
127
+          HRB 79808<br/>
128
+          VAT ID No.: DE 814160246<br/>
129
+        </p>
130
+        <p>DB Vertrieb GmbH is represented by the Chairman of the Management Board Georg Lauber, the Managing Director responsible for Digital Business, Nils Hartgen and the Managing Director responsible for Finance & Controlling, Dr. Christian Runzheimer.</p>
131
+      </div>
132
+
133
+      <div style="margin-top:16px;padding:0;border:0;background-color:#f00;height:32px;text-align:right;vertival-align:bottom;">
134
+        <p style="padding-top:10px;">
135
+          <span style="padding-right:40px;color:#fff">&copy;&nbsp;Deutsche Bahn AG&nbsp;</span>
136
+        </p>
137
+      </div>
138
+    </div>
139
+	<p class="webtrack">
140
+	  <img src="http://t.bahn.de/b/ss/dbbahnprod/1/H.20.3--NS/996711116?pageName=BAHN_ASK_DEU_DE_BAHN_PushServiceMail&amp;ch=BAHN_ASK_DEU_DE_BAHN&amp;events=event48" width="5" height="5" alt="" />
141
+	</p>
142
+</p>
143
+
144
+  </body>
145
+</html>`;