fix: Status design

This commit is contained in:
Christian Pauly 2020-08-23 18:10:33 +02:00
parent effb5b62cc
commit f7930febba
3 changed files with 56 additions and 44 deletions

View file

@ -28,6 +28,7 @@ class PresenceListItem extends StatelessWidget {
final user = room.getUserByMXIDSync(room.directChatMatrixID); final user = room.getUserByMXIDSync(room.directChatMatrixID);
final presence = final presence =
Matrix.of(context).client.presences[room.directChatMatrixID]; Matrix.of(context).client.presences[room.directChatMatrixID];
final hasStatus = presence?.presence?.statusMsg != null;
return InkWell( return InkWell(
onTap: () => presence?.presence?.statusMsg == null onTap: () => presence?.presence?.statusMsg == null
? _startChatAction(context, user.id) ? _startChatAction(context, user.id)
@ -45,14 +46,29 @@ class PresenceListItem extends StatelessWidget {
children: <Widget>[ children: <Widget>[
SizedBox(height: 16), SizedBox(height: 16),
Container( Container(
child: Avatar(user.avatarUrl, user.calcDisplayname()), child: Stack(
children: [
Avatar(user.avatarUrl, user.calcDisplayname()),
if (presence?.presence?.currentlyActive == true)
Positioned(
bottom: 0,
right: 0,
child: Container(
width: 10,
height: 10,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: Colors.green,
),
),
),
],
),
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border.all( border: Border.all(
width: 1, width: 1,
color: presence?.presence?.statusMsg == null color: !hasStatus
? presence?.presence?.currentlyActive == true ? Theme.of(context).secondaryHeaderColor
? Colors.blue
: Theme.of(context).secondaryHeaderColor
: Theme.of(context).primaryColor, : Theme.of(context).primaryColor,
), ),
borderRadius: BorderRadius.circular(80), borderRadius: BorderRadius.circular(80),
@ -70,7 +86,7 @@ class PresenceListItem extends StatelessWidget {
.textTheme .textTheme
.bodyText2 .bodyText2
.color .color
.withOpacity(0.66), .withOpacity(hasStatus ? 1 : 0.66),
fontSize: 13, fontSize: 13,
), ),
), ),

View file

@ -8,11 +8,14 @@ extension PresenceExtension on Presence {
if (presence.statusMsg?.isNotEmpty ?? false) { if (presence.statusMsg?.isNotEmpty ?? false) {
return presence.statusMsg; return presence.statusMsg;
} }
if (presence.lastActiveAgo != null) { if (presence.lastActiveAgo != null ?? presence.lastActiveAgo != 0) {
return L10n.of(context).lastActiveAgo( return L10n.of(context).lastActiveAgo(
DateTime.fromMillisecondsSinceEpoch(presence.lastActiveAgo) DateTime.fromMillisecondsSinceEpoch(presence.lastActiveAgo)
.localizedTimeShort(context)); .localizedTimeShort(context));
} }
if (presence.currentlyActive) {
return L10n.of(context).currentlyActive;
}
return L10n.of(context).lastSeenLongTimeAgo; return L10n.of(context).lastSeenLongTimeAgo;
} }
} }

View file

@ -49,7 +49,7 @@ packages:
name: async name: async
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.4.2" version: "2.5.0-nullsafety"
base58check: base58check:
dependency: transitive dependency: transitive
description: description:
@ -63,7 +63,7 @@ packages:
name: boolean_selector name: boolean_selector
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.0" version: "2.1.0-nullsafety"
bot_toast: bot_toast:
dependency: "direct main" dependency: "direct main"
description: description:
@ -91,14 +91,14 @@ packages:
name: characters name: characters
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.0" version: "1.1.0-nullsafety.2"
charcode: charcode:
dependency: transitive dependency: transitive
description: description:
name: charcode name: charcode
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.3" version: "1.2.0-nullsafety"
cli_util: cli_util:
dependency: transitive dependency: transitive
description: description:
@ -112,14 +112,14 @@ packages:
name: clock name: clock
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.1" version: "1.1.0-nullsafety"
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.13" version: "1.15.0-nullsafety.2"
convert: convert:
dependency: transitive dependency: transitive
description: description:
@ -175,13 +175,13 @@ packages:
name: fake_async name: fake_async
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.0" version: "1.1.0-nullsafety"
famedlysdk: famedlysdk:
dependency: "direct main" dependency: "direct main"
description: description:
path: "." path: "."
ref: "50d97ebeb224dcbfa8e306b8cb50adcaee12d4db" ref: "09ffa0940484862139c3fe431d4c3ef3392f2232"
resolved-ref: "50d97ebeb224dcbfa8e306b8cb50adcaee12d4db" resolved-ref: "09ffa0940484862139c3fe431d4c3ef3392f2232"
url: "https://gitlab.com/famedly/famedlysdk.git" url: "https://gitlab.com/famedly/famedlysdk.git"
source: git source: git
version: "0.0.1" version: "0.0.1"
@ -425,7 +425,7 @@ packages:
name: js name: js
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.6.2" version: "0.6.3-nullsafety"
link_text: link_text:
dependency: "direct main" dependency: "direct main"
description: description:
@ -460,7 +460,7 @@ packages:
name: matcher name: matcher
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.12.8" version: "0.12.10-nullsafety"
matrix_file_e2ee: matrix_file_e2ee:
dependency: transitive dependency: transitive
description: description:
@ -481,7 +481,7 @@ packages:
name: meta name: meta
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.8" version: "1.3.0-nullsafety.2"
mime: mime:
dependency: transitive dependency: transitive
description: description:
@ -502,14 +502,7 @@ packages:
name: moor name: moor
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.3.0" version: "3.3.1"
moor_ffi:
dependency: "direct main"
description:
name: moor_ffi
url: "https://pub.dartlang.org"
source: hosted
version: "0.5.0"
node_interop: node_interop:
dependency: transitive dependency: transitive
description: description:
@ -565,7 +558,7 @@ packages:
name: path name: path
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.7.0" version: "1.8.0-nullsafety"
path_drawing: path_drawing:
dependency: transitive dependency: transitive
description: description:
@ -614,7 +607,7 @@ packages:
name: pedantic name: pedantic
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.9.0" version: "1.10.0-nullsafety"
petitparser: petitparser:
dependency: transitive dependency: transitive
description: description:
@ -663,7 +656,7 @@ packages:
name: pool name: pool
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.4.0" version: "1.5.0-nullsafety"
process: process:
dependency: transitive dependency: transitive
description: description:
@ -738,21 +731,21 @@ packages:
name: source_map_stack_trace name: source_map_stack_trace
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.0" version: "2.1.0-nullsafety.1"
source_maps: source_maps:
dependency: transitive dependency: transitive
description: description:
name: source_maps name: source_maps
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.10.9" version: "0.10.10-nullsafety"
source_span: source_span:
dependency: transitive dependency: transitive
description: description:
name: source_span name: source_span
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.7.0" version: "1.8.0-nullsafety"
sqflite: sqflite:
dependency: "direct main" dependency: "direct main"
description: description:
@ -768,7 +761,7 @@ packages:
source: hosted source: hosted
version: "1.0.2+1" version: "1.0.2+1"
sqlite3: sqlite3:
dependency: transitive dependency: "direct main"
description: description:
name: sqlite3 name: sqlite3
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
@ -780,21 +773,21 @@ packages:
name: stack_trace name: stack_trace
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.9.5" version: "1.10.0-nullsafety"
stream_channel: stream_channel:
dependency: transitive dependency: transitive
description: description:
name: stream_channel name: stream_channel
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.0" version: "2.1.0-nullsafety"
string_scanner: string_scanner:
dependency: transitive dependency: transitive
description: description:
name: string_scanner name: string_scanner
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.5" version: "1.1.0-nullsafety"
synchronized: synchronized:
dependency: transitive dependency: transitive
description: description:
@ -808,35 +801,35 @@ packages:
name: term_glyph name: term_glyph
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.0" version: "1.2.0-nullsafety"
test: test:
dependency: transitive dependency: transitive
description: description:
name: test name: test
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.15.2" version: "1.16.0-nullsafety.1"
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.17" version: "0.2.19-nullsafety"
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.3.10" version: "0.3.12-nullsafety.1"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
name: typed_data name: typed_data
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0" version: "1.3.0-nullsafety.2"
universal_html: universal_html:
dependency: "direct main" dependency: "direct main"
description: description:
@ -899,7 +892,7 @@ packages:
name: vector_math name: vector_math
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.8" version: "2.1.0-nullsafety.2"
vm_service: vm_service:
dependency: transitive dependency: transitive
description: description:
@ -964,5 +957,5 @@ packages:
source: hosted source: hosted
version: "0.1.2" version: "0.1.2"
sdks: sdks:
dart: ">=2.9.0-14.0.dev <3.0.0" dart: ">=2.10.0-0.0.dev <2.10.0"
flutter: ">=1.18.0-6.0.pre <2.0.0" flutter: ">=1.18.0-6.0.pre <2.0.0"