Enable skia in web

This commit is contained in:
Christian Pauly 2020-04-08 12:38:52 +02:00
parent 7a21d15f11
commit 10f6d8d652
8 changed files with 104 additions and 150 deletions

View File

@ -32,7 +32,7 @@ build_web:
- cd assets/js/ && tar xaf olm.tar.gz && cd ../../ - cd assets/js/ && tar xaf olm.tar.gz && cd ../../
- flutter pub get - flutter pub get
- flutter clean - flutter clean
- flutter build web --release --verbose - flutter build web --release --verbose --dart-define=FLUTTER_WEB_USE_SKIA=true
artifacts: artifacts:
paths: paths:
- build/web/ - build/web/

View File

@ -1,8 +1,8 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/utils/string_color.dart'; import 'package:fluffychat/utils/string_color.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_advanced_networkimage/provider.dart';
import 'matrix.dart'; import 'matrix.dart';
@ -40,13 +40,7 @@ class Avatar extends StatelessWidget {
child: CircleAvatar( child: CircleAvatar(
radius: size / 2, radius: size / 2,
backgroundImage: mxContent.mxc?.isNotEmpty ?? false backgroundImage: mxContent.mxc?.isNotEmpty ?? false
? kIsWeb ? AdvancedNetworkImage(src)
? NetworkImage(
src,
)
: CachedNetworkImageProvider(
src,
)
: null, : null,
backgroundColor: mxContent.mxc.isEmpty backgroundColor: mxContent.mxc.isEmpty
? name?.color ?? Theme.of(context).secondaryHeaderColor ? name?.color ?? Theme.of(context).secondaryHeaderColor

View File

@ -1,8 +1,7 @@
import 'package:cached_network_image/cached_network_image.dart';
import 'package:famedlysdk/famedlysdk.dart'; import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/views/image_viewer.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_advanced_networkimage/provider.dart';
import 'matrix.dart'; import 'matrix.dart';
@ -32,55 +31,44 @@ class ContentBanner extends StatelessWidget {
height: bannerSize, height: bannerSize,
method: ThumbnailMethod.scale, method: ThumbnailMethod.scale,
); );
return InkWell( return Container(
onTap: () => mxContent.mxc?.isNotEmpty ?? false height: 300,
? ImageViewer.show(context, mxContent) alignment: Alignment.center,
: null, decoration: BoxDecoration(
child: Container( color: Theme.of(context).secondaryHeaderColor,
height: 300, ),
alignment: Alignment.center, child: Stack(
decoration: BoxDecoration( children: <Widget>[
color: Theme.of(context).secondaryHeaderColor, Positioned(
), left: 0,
child: Stack( right: 0,
children: <Widget>[ top: 0,
Positioned( bottom: 0,
left: 0, child: Opacity(
right: 0, opacity: 0.75,
top: 0, child: !loading
bottom: 0, ? mxContent.mxc?.isNotEmpty ?? false
child: Opacity( ? Image(
opacity: 0.75, height: 300,
child: !loading fit: BoxFit.cover,
? mxContent.mxc?.isNotEmpty ?? false image: AdvancedNetworkImage(src),
? kIsWeb )
? Image.network( : Icon(defaultIcon, size: 300)
src, : Icon(defaultIcon, size: 300),
height: 300, ),
fit: BoxFit.cover, ),
) if (this.onEdit != null)
: CachedNetworkImage( Container(
imageUrl: src, margin: EdgeInsets.all(8),
height: 300, alignment: Alignment.bottomRight,
fit: BoxFit.cover, child: FloatingActionButton(
) mini: true,
: Icon(defaultIcon, size: 300) backgroundColor: Theme.of(context).primaryColor,
: Icon(defaultIcon, size: 300), child: Icon(Icons.camera_alt),
onPressed: onEdit,
), ),
), ),
if (this.onEdit != null) ],
Container(
margin: EdgeInsets.all(8),
alignment: Alignment.bottomRight,
child: FloatingActionButton(
mini: true,
backgroundColor: Theme.of(context).primaryColor,
child: Icon(Icons.camera_alt),
onPressed: onEdit,
),
),
],
),
), ),
); );
} }

View File

@ -6,7 +6,6 @@ import 'package:fluffychat/i18n/i18n.dart';
import 'package:fluffychat/utils/date_time_extension.dart'; import 'package:fluffychat/utils/date_time_extension.dart';
import 'package:fluffychat/utils/event_extension.dart'; import 'package:fluffychat/utils/event_extension.dart';
import 'package:fluffychat/utils/string_color.dart'; import 'package:fluffychat/utils/string_color.dart';
import 'package:fluffychat/views/image_viewer.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../avatar.dart'; import '../avatar.dart';
@ -17,6 +16,7 @@ class Message extends StatelessWidget {
final Event event; final Event event;
final Event nextEvent; final Event nextEvent;
final Function(Event) onSelect; final Function(Event) onSelect;
final Function(Event) onAvatarTab;
final bool longPressSelect; final bool longPressSelect;
final bool selected; final bool selected;
final Timeline timeline; final Timeline timeline;
@ -25,6 +25,7 @@ class Message extends StatelessWidget {
{this.nextEvent, {this.nextEvent,
this.longPressSelect, this.longPressSelect,
this.onSelect, this.onSelect,
this.onAvatarTab,
this.selected, this.selected,
this.timeline}); this.timeline});
@ -119,11 +120,13 @@ class Message extends StatelessWidget {
.tryRequestWithLoadingDialog(event.requestKey()), .tryRequestWithLoadingDialog(event.requestKey()),
), ),
SizedBox(height: 4), SizedBox(height: 4),
_MetaRow( Opacity(
event, opacity: 0,
ownMessage, child: _MetaRow(
textColor, event,
invisible: true, ownMessage,
textColor,
),
), ),
], ],
), ),
@ -147,7 +150,7 @@ class Message extends StatelessWidget {
: Avatar( : Avatar(
event.sender.avatarUrl, event.sender.avatarUrl,
event.sender.calcDisplayname(), event.sender.calcDisplayname(),
onTap: () => ImageViewer.show(context, event.sender.avatarUrl), onTap: () => onAvatarTab(event),
); );
if (ownMessage) { if (ownMessage) {
rowChildren.add(avatarOrSizedBox); rowChildren.add(avatarOrSizedBox);
@ -181,12 +184,10 @@ class Message extends StatelessWidget {
class _MetaRow extends StatelessWidget { class _MetaRow extends StatelessWidget {
final Event event; final Event event;
final bool invisible;
final bool ownMessage; final bool ownMessage;
final Color color; final Color color;
const _MetaRow(this.event, this.ownMessage, this.color, const _MetaRow(this.event, this.ownMessage, this.color, {Key key})
{this.invisible = false, Key key})
: super(key: key); : super(key: key);
@override @override
@ -203,14 +204,14 @@ class _MetaRow extends StatelessWidget {
style: TextStyle( style: TextStyle(
fontSize: 11, fontSize: 11,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
color: invisible ? Colors.transparent : displayname.color, color: displayname.color,
), ),
), ),
if (showDisplayname) SizedBox(width: 4), if (showDisplayname) SizedBox(width: 4),
Text( Text(
event.time.localizedTime(context), event.time.localizedTime(context),
style: TextStyle( style: TextStyle(
color: invisible ? Colors.transparent : color, color: color,
fontSize: 11, fontSize: 11,
), ),
), ),

View File

@ -496,7 +496,9 @@ class _ChatState extends State<_Chat> {
), ),
) )
: Message(timeline.events[i - 1], : Message(timeline.events[i - 1],
onSelect: (Event event) { onAvatarTab: (Event event) {
sendController.text += ' ${event.senderId}';
}, onSelect: (Event event) {
if (!event.redacted) { if (!event.redacted) {
if (selectedEvents.contains(event)) { if (selectedEvents.contains(event)) {
setState( setState(

View File

@ -1,45 +0,0 @@
import 'package:famedlysdk/famedlysdk.dart';
import 'package:fluffychat/components/matrix.dart';
import 'package:fluffychat/utils/app_route.dart';
import 'package:flutter/material.dart';
import 'package:photo_view/photo_view.dart';
import 'package:url_launcher/url_launcher.dart';
class ImageViewer extends StatelessWidget {
final MxContent mxContent;
const ImageViewer(this.mxContent);
static show(BuildContext context, MxContent content) {
Navigator.of(context).push(
AppRoute(
ImageViewer(content),
),
);
}
@override
Widget build(BuildContext context) {
final String url = mxContent.getDownloadLink(Matrix.of(context).client);
return Scaffold(
backgroundColor: Colors.black,
appBar: AppBar(
brightness: Brightness.dark,
backgroundColor: Colors.black,
iconTheme: IconThemeData(color: Colors.white),
actions: <Widget>[
IconButton(
icon: Icon(Icons.file_download),
onPressed: () => launch(url),
),
],
),
body: PhotoView(
loadingBuilder: (c, i) => Center(child: CircularProgressIndicator()),
imageProvider: NetworkImage(
url,
),
),
);
}
}

View File

@ -21,28 +21,28 @@ packages:
name: archive name: archive
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.11" version: "2.0.13"
args: args:
dependency: transitive dependency: transitive
description: description:
name: args name: args
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.5.2" version: "1.6.0"
async: async:
dependency: transitive dependency: transitive
description: description:
name: async name: async
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.4.0" version: "2.4.1"
boolean_selector: boolean_selector:
dependency: transitive dependency: transitive
description: description:
name: boolean_selector name: boolean_selector
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.5" version: "2.0.0"
bubble: bubble:
dependency: "direct main" dependency: "direct main"
description: description:
@ -50,13 +50,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.9+1" version: "1.1.9+1"
cached_network_image:
dependency: "direct main"
description:
name: cached_network_image
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
canonical_json: canonical_json:
dependency: transitive dependency: transitive
description: description:
@ -70,14 +63,14 @@ packages:
name: charcode name: charcode
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.2" version: "1.1.3"
collection: collection:
dependency: transitive dependency: transitive
description: description:
name: collection name: collection
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.14.11" version: "1.14.12"
convert: convert:
dependency: transitive dependency: transitive
description: description:
@ -98,7 +91,7 @@ packages:
name: crypto name: crypto
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.3" version: "2.1.4"
csslib: csslib:
dependency: transitive dependency: transitive
description: description:
@ -155,13 +148,13 @@ packages:
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" version: "0.0.0"
flutter_cache_manager: flutter_advanced_networkimage:
dependency: transitive dependency: "direct main"
description: description:
name: flutter_cache_manager name: flutter_advanced_networkimage
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.3" version: "0.6.4"
flutter_launcher_icons: flutter_launcher_icons:
dependency: "direct dev" dependency: "direct dev"
description: description:
@ -209,6 +202,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.5" version: "1.2.5"
flutter_svg:
dependency: transitive
description:
name: flutter_svg
url: "https://pub.dartlang.org"
source: hosted
version: "0.17.4"
flutter_test: flutter_test:
dependency: "direct dev" dependency: "direct dev"
description: flutter description: flutter
@ -260,7 +260,7 @@ packages:
name: image name: image
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.4" version: "2.1.12"
image_picker: image_picker:
dependency: "direct main" dependency: "direct main"
description: description:
@ -274,7 +274,7 @@ packages:
name: intl name: intl
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.16.0" version: "0.16.1"
intl_translation: intl_translation:
dependency: "direct main" dependency: "direct main"
description: description:
@ -419,6 +419,20 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.6.4" version: "1.6.4"
path_drawing:
dependency: transitive
description:
name: path_drawing
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.1"
path_parsing:
dependency: transitive
description:
name: path_parsing
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.4"
path_provider: path_provider:
dependency: "direct main" dependency: "direct main"
description: description:
@ -488,7 +502,7 @@ packages:
name: quiver name: quiver
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.5" version: "2.1.3"
receive_sharing_intent: receive_sharing_intent:
dependency: "direct main" dependency: "direct main"
description: description:
@ -556,7 +570,7 @@ packages:
name: source_span name: source_span
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.5.5" version: "1.7.0"
sqflite: sqflite:
dependency: "direct main" dependency: "direct main"
description: description:
@ -605,21 +619,21 @@ packages:
name: test name: test
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.9.4" version: "1.13.0"
test_api: test_api:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.2.11" version: "0.2.15"
test_core: test_core:
dependency: transitive dependency: transitive
description: description:
name: test_core name: test_core
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.2.15" version: "0.3.1"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
@ -676,13 +690,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.1.0+2" version: "0.1.0+2"
uuid:
dependency: transitive
description:
name: uuid
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.4"
vector_math: vector_math:
dependency: transitive dependency: transitive
description: description:
@ -711,6 +718,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.0" version: "1.1.0"
webkit_inspection_protocol:
dependency: transitive
description:
name: webkit_inspection_protocol
url: "https://pub.dartlang.org"
source: hosted
version: "0.5.0+1"
webview_flutter: webview_flutter:
dependency: "direct main" dependency: "direct main"
description: description:
@ -724,7 +738,7 @@ packages:
name: xml name: xml
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.5.0" version: "3.6.1"
yaml: yaml:
dependency: transitive dependency: transitive
description: description:

View File

@ -37,7 +37,7 @@ dependencies:
url_launcher: ^5.4.1 url_launcher: ^5.4.1
url_launcher_web: ^0.1.0 url_launcher_web: ^0.1.0
sqflite: ^1.2.0 sqflite: ^1.2.0
cached_network_image: ^2.0.0 flutter_advanced_networkimage: any
firebase_messaging: ^6.0.9 firebase_messaging: ^6.0.9
flutter_local_notifications: ^0.9.1+2 flutter_local_notifications: ^0.9.1+2
link_text: ^0.1.1 link_text: ^0.1.1