feat: add localizations

This commit is contained in:
Gordon Hayes
2021-08-24 11:39:49 +02:00
parent 6ee296ed1b
commit d372224416
20 changed files with 745 additions and 123 deletions
@@ -1,11 +1,10 @@
import 'dart:async';
import 'package:collection/collection.dart' show IterableExtension;
import 'package:example/localizations.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:jiffy/jiffy.dart';
import 'package:stream_chat_flutter/src/option_list_tile.dart';
import 'package:stream_chat_flutter/src/stream_svg_icon.dart';
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
import 'channel_file_display_screen.dart';
@@ -106,7 +105,7 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
builder: (context, state) {
if (!state.hasData) {
return Text(
'Loading...',
AppLocalizations.of(context).loading,
style: TextStyle(
color: StreamChatTheme.of(context)
.colorTheme
@@ -139,7 +138,7 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
height: 3.0,
),
Text(
'${channel.channel.memberCount} Members, ${snapshot.data?.where((e) => e.user!.online).length ?? 0} Online',
'${channel.channel.memberCount} ${AppLocalizations.of(context).members}, ${snapshot.data?.where((e) => e.user!.online).length ?? 0} ${AppLocalizations.of(context).online}',
style: TextStyle(
color: StreamChatTheme.of(context)
.colorTheme
@@ -260,7 +259,9 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
member.role == 'owner' ? 'Owner' : '',
member.role == 'owner'
? AppLocalizations.of(context).owner
: '',
style: TextStyle(
color: StreamChatTheme.of(context)
.colorTheme
@@ -313,7 +314,7 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'${members.length - groupMembersLength} more',
'${members.length - groupMembersLength} ${AppLocalizations.of(context).more}',
style: TextStyle(
color: StreamChatTheme.of(context)
.colorTheme
@@ -352,7 +353,7 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
Padding(
padding: const EdgeInsets.all(7.0),
child: Text(
'NAME',
AppLocalizations.of(context).name.toUpperCase(),
style: StreamChatTheme.of(context).textTheme.footnote.copyWith(
color: StreamChatTheme.of(context)
.colorTheme
@@ -370,7 +371,7 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
cursorColor:
StreamChatTheme.of(context).colorTheme.textHighEmphasis,
decoration: InputDecoration.collapsed(
hintText: 'Add a group name',
hintText: AppLocalizations.of(context).addAGroupName,
hintStyle: StreamChatTheme.of(context)
.textTheme
.bodyBold
@@ -457,7 +458,7 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
return OptionListTile(
tileColor: StreamChatTheme.of(context).colorTheme.appBg,
separatorColor: StreamChatTheme.of(context).colorTheme.disabled,
title: 'Mute group',
title: AppLocalizations.of(context).muteGroup,
titleTextStyle: StreamChatTheme.of(context).textTheme.body,
leading: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
@@ -491,7 +492,7 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
);
}),
OptionListTile(
title: 'Pinned Messages',
title: AppLocalizations.of(context).pinnedMessages,
tileColor: StreamChatTheme.of(context).colorTheme.appBg,
titleTextStyle: StreamChatTheme.of(context).textTheme.body,
leading: Padding(
@@ -554,7 +555,7 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
OptionListTile(
tileColor: StreamChatTheme.of(context).colorTheme.appBg,
separatorColor: StreamChatTheme.of(context).colorTheme.disabled,
title: 'Photos & Videos',
title: AppLocalizations.of(context).photosAndVideos,
titleTextStyle: StreamChatTheme.of(context).textTheme.body,
leading: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12.0),
@@ -616,7 +617,7 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
OptionListTile(
tileColor: StreamChatTheme.of(context).colorTheme.appBg,
separatorColor: StreamChatTheme.of(context).colorTheme.disabled,
title: 'Files',
title: AppLocalizations.of(context).files,
titleTextStyle: StreamChatTheme.of(context).textTheme.body,
leading: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12.0),
@@ -659,7 +660,7 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
OptionListTile(
tileColor: StreamChatTheme.of(context).colorTheme.appBg,
separatorColor: StreamChatTheme.of(context).colorTheme.disabled,
title: 'Leave Group',
title: AppLocalizations.of(context).leaveGroup,
titleTextStyle: StreamChatTheme.of(context).textTheme.body,
leading: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
@@ -678,10 +679,11 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
onTap: () async {
final res = await showConfirmationDialog(
context,
title: 'Leave conversation',
okText: 'LEAVE',
question: 'Are you sure you want to leave this conversation?',
cancelText: 'CANCEL',
title: AppLocalizations.of(context).leaveConversation,
okText: AppLocalizations.of(context).leave.toUpperCase(),
question:
AppLocalizations.of(context).leaveConversationAreYouSure,
cancelText: AppLocalizations.of(context).cancel.toUpperCase(),
icon: StreamSvgIcon.userRemove(
color: StreamChatTheme.of(context).colorTheme.accentError,
),
@@ -777,8 +779,8 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
.textLowEmphasis,
),
),
Text(
'No user matches these keywords...'),
Text(AppLocalizations.of(context)
.noUserMatchesTheseKeywords),
],
),
),
@@ -815,7 +817,7 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
cursorColor: theme.colorTheme.textHighEmphasis,
autofocus: true,
decoration: InputDecoration(
hintText: 'Search',
hintText: AppLocalizations.of(context).search,
hintStyle: theme.textTheme.body.copyWith(
color: theme.colorTheme.textLowEmphasis,
),
@@ -916,7 +918,7 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
.textLowEmphasis,
size: 24.0,
),
'View info',
AppLocalizations.of(context).viewInfo,
() async {
var client = StreamChat.of(context).client;
@@ -952,7 +954,7 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
.textLowEmphasis,
size: 24.0,
),
'Message',
AppLocalizations.of(context).message,
() async {
var client = StreamChat.of(context).client;
@@ -999,14 +1001,16 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
.accentError,
size: 24.0,
),
'Remove From Group', () async {
AppLocalizations.of(context).removeFromGroup, () async {
final res = await showConfirmationDialog(
context,
title: 'Remove member',
okText: 'REMOVE',
title: AppLocalizations.of(context).removeMember,
okText:
AppLocalizations.of(context).remove.toUpperCase(),
question:
'Are you sure you want to remove this member?',
cancelText: 'CANCEL',
AppLocalizations.of(context).removeMemberAreYouSure,
cancelText:
AppLocalizations.of(context).cancel.toUpperCase(),
);
if (res == true) {
@@ -1024,7 +1028,7 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
.textLowEmphasis,
size: 24.0,
),
'Cancel', () {
AppLocalizations.of(context).cancel, () {
Navigator.pop(context);
}),
],
@@ -1050,7 +1054,7 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
if (otherMember != null) {
if (otherMember.online) {
alternativeWidget = Text(
'Online',
AppLocalizations.of(context).online,
style: TextStyle(
color: StreamChatTheme.of(context)
.colorTheme
@@ -1059,7 +1063,7 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
);
} else {
alternativeWidget = Text(
'Last seen ${Jiffy(otherMember.lastActive).fromNow()}',
'${AppLocalizations.of(context).lastSeen} ${Jiffy(otherMember.lastActive).fromNow()}',
style: TextStyle(
color: StreamChatTheme.of(context)
.colorTheme
@@ -1139,7 +1143,7 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
title =
'${currentMembers.map((e) => e.user!.name).join(', ')} ${exceedingMembers > 0 ? '+ $exceedingMembers' : ''}';
} else {
title = 'No title';
title = AppLocalizations.of(context).noTitle;
}
} else {
title = extraData['name'];
@@ -1149,9 +1153,9 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
String _getLastSeen(User user) {
if (user.online) {
return 'Online';
return AppLocalizations.of(context).online;
} else {
return 'Last seen ${Jiffy(user.lastActive).fromNow()}';
return '${AppLocalizations.of(context).lastSeen} ${Jiffy(user.lastActive).fromNow()}';
}
}
}