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

TW-1996-removed-activated-status-in-accounts-tab #2005

Merged
merged 4 commits into from
Sep 16, 2024
Merged
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
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)
hoangdat marked this conversation as resolved.
Show resolved Hide resolved
ContactStatusWidget(
status: contact.status!,
),
Expand Down
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),
hoangdat marked this conversation as resolved.
Show resolved Hide resolved
),
),
);

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);
});
});
}