Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed news screen content not showing in iOS #202

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 12 additions & 18 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,12 @@ PODS:
- "GoogleUtilities/NSData+zlib (~> 6.2)"
- Protobuf (>= 3.9.2, ~> 3.9)
- Flutter (1.0.0)
- flutter_plugin_android_lifecycle (0.0.1):
- Flutter
- FMDB (2.7.5):
- FMDB/standard (= 2.7.5)
- FMDB/standard (2.7.5)
- geolocator (5.3.0):
- geolocator (5.3.1):
- Flutter
- google_api_availability (2.0.3):
- google_api_availability (2.0.4):
- Flutter
- google_maps_flutter (0.0.1):
- Flutter
Expand Down Expand Up @@ -130,7 +128,7 @@ PODS:
- Flutter
- Protobuf (3.10.0)
- Reachability (3.2)
- share (0.5.2):
- share (0.0.1):
- Flutter
- shared_preferences (0.0.1):
- Flutter
Expand All @@ -156,7 +154,6 @@ DEPENDENCIES:
- firebase_messaging (from `.symlinks/plugins/firebase_messaging/ios`)
- firebase_remote_config (from `.symlinks/plugins/firebase_remote_config/ios`)
- Flutter (from `Flutter`)
- flutter_plugin_android_lifecycle (from `.symlinks/plugins/flutter_plugin_android_lifecycle/ios`)
- geolocator (from `.symlinks/plugins/geolocator/ios`)
- google_api_availability (from `.symlinks/plugins/google_api_availability/ios`)
- google_maps_flutter (from `.symlinks/plugins/google_maps_flutter/ios`)
Expand Down Expand Up @@ -207,8 +204,6 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/firebase_remote_config/ios"
Flutter:
:path: Flutter
flutter_plugin_android_lifecycle:
:path: ".symlinks/plugins/flutter_plugin_android_lifecycle/ios"
geolocator:
:path: ".symlinks/plugins/geolocator/ios"
google_api_availability:
Expand Down Expand Up @@ -258,32 +253,31 @@ SPEC CHECKSUMS:
FirebaseMessaging: 35edef69a6af9b34e9e44624089f054be3c09089
FirebaseRemoteConfig: 47abf7a04a9082091955ea555aa79cfdd249b19c
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
flutter_plugin_android_lifecycle: 47de533a02850f070f5696a623995e93eddcdb9b
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
geolocator: 7cdcf71180b80913b3cd84ab715d3b5365b378af
google_api_availability: 526574c9a5a0ae541e18c65f98e47afc11f53c8b
google_maps_flutter: d0dd62f5a7d39bae61057eb9f52dd778d99c7c6c
geolocator: 460cc8e850b616f8c0e90944c86517d91ccbb686
google_api_availability: 15fa42a8cd83c0a6738507ffe6e87096f12abcb8
google_maps_flutter: 78a52114c898b42ea647919679a4c58b70abe876
GoogleAppMeasurement: 434cc7be25e71dc04b8d0e3079125127b330e84a
GoogleDataTransport: 166f9b9f82cbf60a204e8fe2daa9db3e3ec1fb15
GoogleDataTransportCCTSupport: f6ab1962e9dc05ab1fb938b795e5b310209edeec
GoogleMaps: f79af95cb24d869457b1f961c93d3ce8b2f3b848
GoogleUtilities: f895fde57977df4e0233edda0dbeac490e3703b6
location_permissions: 4a49d4e5bec5b653643e551ab77963cc99bb0e4a
nanopb: 2901f78ea1b7b4015c860c2fdd1ea2fee1a18d48
package_info: 48b108e75b8802c2d5e126f208ef540561c98aef
path_provider: fb74bd0465e96b594bb3b5088ee4a4e7bb1f2a9d
package_info: 873975fc26034f0b863a300ad47e7f1ac6c7ec62
path_provider: abfe2b5c733d04e238b0d8691db0cfd63a27a93c
path_provider_macos: f760a3c5b04357c380e2fddb6f9db6f3015897e0
Protobuf: a4dc852ad69c027ca2166ed287b856697814375b
Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96
share: bae0a282aab4483288913fc4dc0b935d4b491f2e
shared_preferences: 430726339841afefe5142b9c1f50cb6bd7793e01
share: 0b2c3e82132f5888bccca3351c504d0003b3b410
shared_preferences: af6bfa751691cdc24be3045c43ec037377ada40d
shared_preferences_macos: f3f29b71ccbb56bf40c9dd6396c9acf15e214087
shared_preferences_web: 141cce0c3ed1a1c5bf2a0e44f52d31eeb66e5ea9
sqflite: 4001a31ff81d210346b500c55b17f4d6c7589dd0
url_launcher: a1c0cc845906122c4784c542523d8cacbded5626
url_launcher: 6fef411d543ceb26efce54b05a0a40bfd74cbbef
url_launcher_macos: fd7894421cd39320dce5f292fc99ea9270b2a313
url_launcher_web: e5527357f037c87560776e36436bf2b0288b965c
webview_flutter: bec7599de6bfbe8008a739aa3ebd7b364ea9d0cd
webview_flutter: d2b4d6c66968ad042ad94cbb791f5b72b4678a96

PODFILE CHECKSUM: 1b66dae606f75376c5f2135a8290850eeb09ae83

Expand Down
45 changes: 26 additions & 19 deletions lib/page/screen/news_detail_screen.dart
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
import 'dart:convert';

import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:flutter_html/rich_text_parser.dart';
import 'package:intl/intl.dart';
import 'package:selftrackingapp/models/message_type.dart';
import 'package:selftrackingapp/models/news_article.dart';
import 'package:selftrackingapp/networking/api_client.dart';
import 'package:selftrackingapp/theme.dart';
import 'package:selftrackingapp/widgets/custom_text.dart';
import 'package:share/share.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:webview_flutter/webview_flutter.dart';

import '../../app_localizations.dart';

import 'package:intl/intl.dart';

DateFormat dateFormat = DateFormat("dd-MM-yy HH:mm");

class NewsDetailScreen extends StatefulWidget {
Expand All @@ -29,10 +20,24 @@ class NewsDetailScreen extends StatefulWidget {
}

class _NewsDetailScreenState extends State<NewsDetailScreen> {
String _initialUrl;

@override
void initState() {
super.initState();
print(widget.article.message);

// Adding meta so that it displays the correct size in iOS
// setting sans-serif font to the content
var content = """<!DOCTYPE html>
<html>
<head><meta name='viewport' content='width=device-width, initial-scale=1.0'></head>
<body style='margin: 0; padding: 0; font-family:Verdana, Geneva, sans-serif;'>
${widget.article.message}
</body>
</html>""";
_initialUrl = Uri.dataFromString(content,
mimeType: 'text/html', encoding: Encoding.getByName('utf-8'))
.toString();
}

void _shareArticle(NewsArticle article) {
Expand Down Expand Up @@ -157,19 +162,21 @@ class _NewsDetailScreenState extends State<NewsDetailScreen> {
Divider(),
Expanded(
child: WebView(
initialUrl: Uri.dataFromString(
widget.article.message,
mimeType: 'text/html',
encoding: Encoding.getByName('utf-8'))
.toString(),
initialUrl: _initialUrl,
navigationDelegate:
(NavigationRequest request) async {
if (await canLaunch(request.url)) {
await launch(request.url);
} else {
print("Cannot launch url");
}
return NavigationDecision.prevent;

// Workaround for content not showing in iOS
// as described here
// [https://github.com/flutter/flutter/issues/30256]
return request.url == _initialUrl
? NavigationDecision.navigate
: NavigationDecision.prevent;
},
javascriptMode: JavascriptMode.unrestricted,
),
Expand All @@ -180,7 +187,7 @@ class _NewsDetailScreenState extends State<NewsDetailScreen> {
))));
}

// var testhtml =
// "<div style=\"text-align: justify;\">\n <h2 style=\"line-height: 40.8%;\">What is Lorem Ipsum?</h2><p></p><p><strong>Lorem Ipsum</strong>&nbsp;is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p><h2 style=\"line-height: 40.8%;\">Why do we use it?</h2><p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here',</p><ol><li>one</li><li>two</li><li>three</li></ol><p></p>\n</div>";
// var testhtml =
// "<div style=\"text-align: justify;\">\n <h2 style=\"line-height: 40.8%;\">What is Lorem Ipsum?</h2><p></p><p><strong>Lorem Ipsum</strong>&nbsp;is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p><h2 style=\"line-height: 40.8%;\">Why do we use it?</h2><p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here',</p><ol><li>one</li><li>two</li><li>three</li></ol><p></p>\n</div>";

}