Skip to content

Commit

Permalink
TW-1996-removed-activated-status-in-accounts-tab (#2005)
Browse files Browse the repository at this point in the history
  • Loading branch information
KhaledNjim committed Sep 16, 2024
1 parent 2b787a7 commit 1bd7682
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 23 deletions.
38 changes: 16 additions & 22 deletions lib/pages/new_private_chat/widget/contact_status_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,30 @@ class ContactStatusWidget extends StatelessWidget {
required this.status,
});

final Color? activeColor = LinagoraRefColors.material().secondary[40];
final Color? inactiveColor = LinagoraRefColors.material().neutral[60];

@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 4.0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SvgPicture.asset(
ImagePaths.icStatus,
// ignore: deprecated_member_use
color: status == ContactStatus.active ? activeColor : inactiveColor,
),
status == ContactStatus.active
? Text(
" ${L10n.of(context)!.online}",
style: Theme.of(context).textTheme.bodySmall?.copyWith(
color: activeColor,
),
)
: Text(
return status == ContactStatus.inactive
? Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 4.0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SvgPicture.asset(
ImagePaths.icStatus,
colorFilter:
ColorFilter.mode(inactiveColor!, BlendMode.srcIn),
),
Text(
" ${L10n.of(context)!.inactive}",
style: Theme.of(context).textTheme.bodySmall?.copyWith(
color: inactiveColor,
),
),
],
),
);
],
),
)
: const SizedBox.shrink();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ class ExpansionContactListTile extends StatelessWidget {
),
],
const SizedBox(width: 8.0),
if (contact.status != null)
if (contact.status != null &&
contact.status == ContactStatus.inactive)
ContactStatusWidget(
status: contact.status!,
),
Expand Down
64 changes: 64 additions & 0 deletions test/pages/new_private_chat/widget/contact_status_widget_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import 'package:fluffychat/pages/new_private_chat/widget/contact_status_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:fluffychat/domain/model/contact/contact_status.dart';
import 'package:linagora_design_flutter/colors/linagora_ref_colors.dart';

void main() {
group('ContactStatusWidget', () {
testWidgets('renders correctly for inactive status',
(WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
localizationsDelegates: L10n.localizationsDelegates,
supportedLocales: L10n.supportedLocales,
home: Scaffold(
body: ContactStatusWidget(status: ContactStatus.inactive),
),
),
);

expect(find.byType(SvgPicture), findsOneWidget);

expect(find.byType(Text), findsOneWidget);

final svgPicture = tester.widget<SvgPicture>(find.byType(SvgPicture));
expect(
svgPicture.colorFilter,
ColorFilter.mode(
LinagoraRefColors.material().neutral[60]!,
BlendMode.srcIn,
),
);

final text = tester.widget<Text>(find.byType(Text));
expect(text.style?.color, LinagoraRefColors.material().neutral[60]);
expect(
text.style?.fontSize,
Theme.of(tester.element(find.byType(ContactStatusWidget)))
.textTheme
.bodySmall
?.fontSize,
);
});

testWidgets('renders correctly for active status',
(WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
localizationsDelegates: L10n.localizationsDelegates,
supportedLocales: L10n.supportedLocales,
home: Scaffold(
body: ContactStatusWidget(status: ContactStatus.active),
),
),
);

expect(find.byType(SvgPicture), findsNothing);
expect(find.byType(Text), findsNothing);
expect(find.byType(SizedBox), findsOneWidget);
});
});
}

0 comments on commit 1bd7682

Please sign in to comment.