Add localizations
This commit is contained in:
parent
1f230c0a63
commit
a776ac1513
28 changed files with 3406 additions and 249 deletions
|
|
@ -2,6 +2,7 @@ import 'package:famedlysdk/famedlysdk.dart';
|
|||
import 'package:fluffychat/components/adaptive_page_layout.dart';
|
||||
import 'package:fluffychat/components/list_items/chat_list_item.dart';
|
||||
import 'package:fluffychat/components/matrix.dart';
|
||||
import 'package:fluffychat/i18n/i18n.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class Archive extends StatefulWidget {
|
||||
|
|
@ -22,7 +23,7 @@ class _ArchiveState extends State<Archive> {
|
|||
return AdaptivePageLayout(
|
||||
firstScaffold: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("Archive"),
|
||||
title: Text(I18n.of(context).archive),
|
||||
),
|
||||
body: FutureBuilder<List<Room>>(
|
||||
future: getArchive(context),
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import 'package:fluffychat/components/matrix.dart';
|
||||
import 'package:fluffychat/i18n/i18n.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:webview_flutter/webview_flutter.dart';
|
||||
|
||||
|
|
@ -16,7 +17,7 @@ class AuthWebView extends StatelessWidget {
|
|||
print(url);
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("Authentication"),
|
||||
title: Text(I18n.of(context).authentication),
|
||||
leading: IconButton(
|
||||
icon: Icon(Icons.arrow_back),
|
||||
onPressed: () {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import 'package:fluffychat/components/adaptive_page_layout.dart';
|
|||
import 'package:fluffychat/components/chat_settings_popup_menu.dart';
|
||||
import 'package:fluffychat/components/list_items/message.dart';
|
||||
import 'package:fluffychat/components/matrix.dart';
|
||||
import 'package:fluffychat/i18n/i18n.dart';
|
||||
import 'package:fluffychat/utils/room_extension.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
|
@ -61,13 +62,16 @@ class _ChatState extends State<Chat> {
|
|||
r.user.id == room.client.userID ||
|
||||
r.user.id == timeline.events.first.senderId);
|
||||
if (lastReceipts.length == 1) {
|
||||
seenByText = "Seen by ${lastReceipts.first.user.calcDisplayname()}";
|
||||
seenByText = I18n.of(context)
|
||||
.seenByUser(lastReceipts.first.user.calcDisplayname());
|
||||
} else if (lastReceipts.length == 2) {
|
||||
seenByText =
|
||||
"Seen by ${lastReceipts.first.user.calcDisplayname()} and ${lastReceipts[1].user.calcDisplayname()}";
|
||||
seenByText = seenByText = I18n.of(context).seenByUserAndUser(
|
||||
lastReceipts.first.user.calcDisplayname(),
|
||||
lastReceipts[1].user.calcDisplayname());
|
||||
} else if (lastReceipts.length > 2) {
|
||||
seenByText =
|
||||
"Seen by ${lastReceipts.first.user.calcDisplayname()} and ${lastReceipts.length - 1} others";
|
||||
seenByText = I18n.of(context).seenByUserAndCountOthers(
|
||||
lastReceipts.first.user.calcDisplayname(),
|
||||
(lastReceipts.length - 1).toString());
|
||||
}
|
||||
}
|
||||
setState(() {
|
||||
|
|
@ -98,7 +102,7 @@ class _ChatState extends State<Chat> {
|
|||
|
||||
void sendFileAction(BuildContext context) async {
|
||||
if (kIsWeb) {
|
||||
return Toast.show("Not supported in web", context);
|
||||
return Toast.show(I18n.of(context).notSupportedInWeb, context);
|
||||
}
|
||||
File file = await FilePicker.getFile();
|
||||
if (file == null) return;
|
||||
|
|
@ -111,7 +115,7 @@ class _ChatState extends State<Chat> {
|
|||
|
||||
void sendImageAction(BuildContext context) async {
|
||||
if (kIsWeb) {
|
||||
return Toast.show("Not supported in web", context);
|
||||
return Toast.show(I18n.of(context).notSupportedInWeb, context);
|
||||
}
|
||||
File file = await ImagePicker.pickImage(
|
||||
source: ImageSource.gallery,
|
||||
|
|
@ -128,7 +132,7 @@ class _ChatState extends State<Chat> {
|
|||
|
||||
void openCameraAction(BuildContext context) async {
|
||||
if (kIsWeb) {
|
||||
return Toast.show("Not supported in web", context);
|
||||
return Toast.show(I18n.of(context).notSupportedInWeb, context);
|
||||
}
|
||||
File file = await ImagePicker.pickImage(
|
||||
source: ImageSource.camera,
|
||||
|
|
@ -149,8 +153,13 @@ class _ChatState extends State<Chat> {
|
|||
Client client = matrix.client;
|
||||
room ??= client.getRoomById(widget.id);
|
||||
if (room == null) {
|
||||
return Center(
|
||||
child: Text("You are no longer participating in this chat"),
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(I18n.of(context).oopsSomethingWentWrong),
|
||||
),
|
||||
body: Center(
|
||||
child: Text(I18n.of(context).youAreNoLongerParticipatingInThisChat),
|
||||
),
|
||||
);
|
||||
}
|
||||
matrix.activeRoomId = widget.id;
|
||||
|
|
@ -164,16 +173,19 @@ class _ChatState extends State<Chat> {
|
|||
typingUsers.removeWhere((User u) => u.id == client.userID);
|
||||
|
||||
if (typingUsers.length == 1) {
|
||||
typingText = "is typing...";
|
||||
typingText = I18n.of(context).isTyping;
|
||||
if (typingUsers.first.id != room.directChatMatrixID) {
|
||||
typingText = typingUsers.first.calcDisplayname() + " " + typingText;
|
||||
typingText =
|
||||
I18n.of(context).userIsTyping(typingUsers.first.calcDisplayname());
|
||||
}
|
||||
} else if (typingUsers.length == 2) {
|
||||
typingText =
|
||||
"${typingUsers.first.calcDisplayname()} and ${typingUsers[1].calcDisplayname()} are typing...";
|
||||
typingText = I18n.of(context).userAndUserAreTyping(
|
||||
typingUsers.first.calcDisplayname(),
|
||||
typingUsers[1].calcDisplayname());
|
||||
} else if (typingUsers.length > 2) {
|
||||
typingText =
|
||||
"${typingUsers.first.calcDisplayname()} and ${typingUsers.length - 1} others are typing...";
|
||||
typingText = I18n.of(context).userAndOthersAreTyping(
|
||||
typingUsers.first.calcDisplayname(),
|
||||
(typingUsers.length - 1).toString());
|
||||
}
|
||||
|
||||
return AdaptivePageLayout(
|
||||
|
|
@ -298,7 +310,7 @@ class _ChatState extends State<Chat> {
|
|||
},
|
||||
itemBuilder: (BuildContext context) =>
|
||||
<PopupMenuEntry<String>>[
|
||||
const PopupMenuItem<String>(
|
||||
PopupMenuItem<String>(
|
||||
value: "file",
|
||||
child: ListTile(
|
||||
leading: CircleAvatar(
|
||||
|
|
@ -306,11 +318,11 @@ class _ChatState extends State<Chat> {
|
|||
foregroundColor: Colors.white,
|
||||
child: Icon(Icons.attachment),
|
||||
),
|
||||
title: Text('Send file'),
|
||||
title: Text(I18n.of(context).sendFile),
|
||||
contentPadding: EdgeInsets.all(0),
|
||||
),
|
||||
),
|
||||
const PopupMenuItem<String>(
|
||||
PopupMenuItem<String>(
|
||||
value: "image",
|
||||
child: ListTile(
|
||||
leading: CircleAvatar(
|
||||
|
|
@ -318,11 +330,11 @@ class _ChatState extends State<Chat> {
|
|||
foregroundColor: Colors.white,
|
||||
child: Icon(Icons.image),
|
||||
),
|
||||
title: Text('Send image'),
|
||||
title: Text(I18n.of(context).sendImage),
|
||||
contentPadding: EdgeInsets.all(0),
|
||||
),
|
||||
),
|
||||
const PopupMenuItem<String>(
|
||||
PopupMenuItem<String>(
|
||||
value: "camera",
|
||||
child: ListTile(
|
||||
leading: CircleAvatar(
|
||||
|
|
@ -330,7 +342,8 @@ class _ChatState extends State<Chat> {
|
|||
foregroundColor: Colors.white,
|
||||
child: Icon(Icons.camera),
|
||||
),
|
||||
title: Text('Open camera'),
|
||||
title:
|
||||
Text(I18n.of(context).openCamera),
|
||||
contentPadding: EdgeInsets.all(0),
|
||||
),
|
||||
),
|
||||
|
|
@ -349,7 +362,7 @@ class _ChatState extends State<Chat> {
|
|||
onSubmitted: (t) => send(),
|
||||
controller: sendController,
|
||||
decoration: InputDecoration(
|
||||
hintText: "Write a message...",
|
||||
hintText: I18n.of(context).writeAMessage,
|
||||
border: InputBorder.none,
|
||||
),
|
||||
onChanged: (String text) {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import 'package:fluffychat/components/chat_settings_popup_menu.dart';
|
|||
import 'package:fluffychat/components/content_banner.dart';
|
||||
import 'package:fluffychat/components/list_items/participant_list_item.dart';
|
||||
import 'package:fluffychat/components/matrix.dart';
|
||||
import 'package:fluffychat/i18n/i18n.dart';
|
||||
import 'package:fluffychat/utils/app_route.dart';
|
||||
import 'package:fluffychat/utils/room_extension.dart';
|
||||
import 'package:fluffychat/utils/room_state_enums_extensions.dart';
|
||||
|
|
@ -37,7 +38,7 @@ class _ChatDetailsState extends State<ChatDetails> {
|
|||
);
|
||||
if (success != false) {
|
||||
Toast.show(
|
||||
"Displayname has been changed",
|
||||
I18n.of(context).displaynameHasBeenChanged,
|
||||
context,
|
||||
duration: Toast.LENGTH_LONG,
|
||||
);
|
||||
|
|
@ -86,7 +87,7 @@ class _ChatDetailsState extends State<ChatDetails> {
|
|||
);
|
||||
if (success != false) {
|
||||
Toast.show(
|
||||
"Group description has been changed",
|
||||
I18n.of(context).groupDescriptionHasBeenChanged,
|
||||
context,
|
||||
duration: Toast.LENGTH_LONG,
|
||||
);
|
||||
|
|
@ -111,7 +112,7 @@ class _ChatDetailsState extends State<ChatDetails> {
|
|||
);
|
||||
if (success != false) {
|
||||
Toast.show(
|
||||
"Avatar has been changed",
|
||||
I18n.of(context).avatarHasBeenChanged,
|
||||
context,
|
||||
duration: Toast.LENGTH_LONG,
|
||||
);
|
||||
|
|
@ -135,8 +136,13 @@ class _ChatDetailsState extends State<ChatDetails> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (widget.room == null) {
|
||||
return Center(
|
||||
child: Text("You are no longer participating in this chat"),
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(I18n.of(context).oopsSomethingWentWrong),
|
||||
),
|
||||
body: Center(
|
||||
child: Text(I18n.of(context).youAreNoLongerParticipatingInThisChat),
|
||||
),
|
||||
);
|
||||
}
|
||||
members ??= widget.room.getParticipants();
|
||||
|
|
@ -161,7 +167,7 @@ class _ChatDetailsState extends State<ChatDetails> {
|
|||
Clipboard.setData(
|
||||
ClipboardData(text: widget.room.canonicalAlias),
|
||||
);
|
||||
Toast.show("Invitation link copied to clipboard", context,
|
||||
Toast.show(I18n.of(context).copiedToClipboard, context,
|
||||
duration: 5);
|
||||
},
|
||||
),
|
||||
|
|
@ -189,12 +195,13 @@ class _ChatDetailsState extends State<ChatDetails> {
|
|||
maxLines: 4,
|
||||
decoration: InputDecoration(
|
||||
border: InputBorder.none,
|
||||
labelText: "Group description:",
|
||||
labelText:
|
||||
"${I18n.of(context).groupDescription}:",
|
||||
labelStyle: TextStyle(
|
||||
color: Theme.of(context).primaryColor,
|
||||
fontWeight: FontWeight.bold),
|
||||
hintText: widget.room.topic ??
|
||||
"Set group description",
|
||||
I18n.of(context).setGroupDescription,
|
||||
),
|
||||
),
|
||||
)
|
||||
|
|
@ -212,7 +219,7 @@ class _ChatDetailsState extends State<ChatDetails> {
|
|||
fontWeight: FontWeight.bold)),
|
||||
subtitle: LinkText(
|
||||
text: widget.room.topic?.isEmpty ?? true
|
||||
? "Add a group description"
|
||||
? I18n.of(context).addGroupDescription
|
||||
: widget.room.topic,
|
||||
linkStyle: TextStyle(color: Colors.blueAccent),
|
||||
textStyle: TextStyle(
|
||||
|
|
@ -227,7 +234,7 @@ class _ChatDetailsState extends State<ChatDetails> {
|
|||
Divider(thickness: 8),
|
||||
ListTile(
|
||||
title: Text(
|
||||
"Settings",
|
||||
I18n.of(context).settings,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).primaryColor,
|
||||
fontWeight: FontWeight.bold,
|
||||
|
|
@ -246,7 +253,7 @@ class _ChatDetailsState extends State<ChatDetails> {
|
|||
onSubmitted: (s) => setDisplaynameAction(context, s),
|
||||
decoration: InputDecoration(
|
||||
border: InputBorder.none,
|
||||
labelText: "Change the name of the group",
|
||||
labelText: I18n.of(context).changeTheNameOfTheGroup,
|
||||
labelStyle: TextStyle(color: Colors.black),
|
||||
hintText:
|
||||
widget.room.getLocalizedDisplayname(context),
|
||||
|
|
@ -267,11 +274,11 @@ class _ChatDetailsState extends State<ChatDetails> {
|
|||
setCanonicalAliasAction(context, s),
|
||||
decoration: InputDecoration(
|
||||
border: InputBorder.none,
|
||||
labelText: "Set invitation link",
|
||||
labelText: I18n.of(context).setInvitationLink,
|
||||
labelStyle: TextStyle(color: Colors.black),
|
||||
hintText: widget.room.canonicalAlias
|
||||
?.replaceAll("#", "") ??
|
||||
"alias",
|
||||
I18n.of(context).alias,
|
||||
prefixText: "#",
|
||||
suffixText: widget.room.client.userID.split(":")[1],
|
||||
),
|
||||
|
|
@ -283,7 +290,8 @@ class _ChatDetailsState extends State<ChatDetails> {
|
|||
backgroundColor: Colors.white,
|
||||
foregroundColor: Colors.grey,
|
||||
child: Icon(Icons.public)),
|
||||
title: Text("Who is allowed to join this group"),
|
||||
title:
|
||||
Text(I18n.of(context).whoIsAllowedToJoinThisGroup),
|
||||
subtitle: Text(
|
||||
widget.room.joinRules.getLocalizedString(context),
|
||||
),
|
||||
|
|
@ -315,7 +323,8 @@ class _ChatDetailsState extends State<ChatDetails> {
|
|||
foregroundColor: Colors.grey,
|
||||
child: Icon(Icons.visibility),
|
||||
),
|
||||
title: Text("Visibility of the chat history"),
|
||||
title:
|
||||
Text(I18n.of(context).visibilityOfTheChatHistory),
|
||||
subtitle: Text(
|
||||
widget.room.historyVisibility
|
||||
.getLocalizedString(context),
|
||||
|
|
@ -361,7 +370,7 @@ class _ChatDetailsState extends State<ChatDetails> {
|
|||
foregroundColor: Colors.grey,
|
||||
child: Icon(Icons.info_outline),
|
||||
),
|
||||
title: Text("Are guest users allowed to join"),
|
||||
title: Text(I18n.of(context).areGuestsAllowedToJoin),
|
||||
subtitle: Text(
|
||||
widget.room.guestAccess.getLocalizedString(context),
|
||||
),
|
||||
|
|
@ -393,8 +402,10 @@ class _ChatDetailsState extends State<ChatDetails> {
|
|||
Divider(thickness: 8),
|
||||
ListTile(
|
||||
title: Text(
|
||||
"$actualMembersCount participant" +
|
||||
(actualMembersCount > 1 ? "s:" : ":"),
|
||||
actualMembersCount > 1
|
||||
? I18n.of(context).countParticipants(
|
||||
actualMembersCount.toString())
|
||||
: I18n.of(context).emptyChat,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).primaryColor,
|
||||
fontWeight: FontWeight.bold,
|
||||
|
|
@ -404,7 +415,7 @@ class _ChatDetailsState extends State<ChatDetails> {
|
|||
Divider(height: 1),
|
||||
widget.room.canInvite
|
||||
? ListTile(
|
||||
title: Text("Invite contact"),
|
||||
title: Text(I18n.of(context).inviteContact),
|
||||
leading: CircleAvatar(
|
||||
child: Icon(Icons.add),
|
||||
backgroundColor: Theme.of(context).primaryColor,
|
||||
|
|
@ -423,8 +434,8 @@ class _ChatDetailsState extends State<ChatDetails> {
|
|||
: i < members.length + 1
|
||||
? ParticipantListItem(members[i - 1])
|
||||
: ListTile(
|
||||
title: Text(
|
||||
"Load more ${actualMembersCount - members.length} participants"),
|
||||
title: Text(I18n.of(context).loadCountMoreParticipants(
|
||||
(actualMembersCount - members.length).toString())),
|
||||
leading: CircleAvatar(
|
||||
backgroundColor: Colors.white,
|
||||
child: Icon(
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import 'package:fluffychat/components/dialogs/new_group_dialog.dart';
|
|||
import 'package:fluffychat/components/dialogs/new_private_chat_dialog.dart';
|
||||
import 'package:fluffychat/components/list_items/chat_list_item.dart';
|
||||
import 'package:fluffychat/components/matrix.dart';
|
||||
import 'package:fluffychat/i18n/i18n.dart';
|
||||
import 'package:fluffychat/utils/app_route.dart';
|
||||
import 'package:fluffychat/utils/url_launcher.dart';
|
||||
import 'package:fluffychat/views/archive.dart';
|
||||
|
|
@ -112,11 +113,13 @@ class _ChatListState extends State<ChatList> {
|
|||
controller: searchController,
|
||||
decoration: InputDecoration(
|
||||
border: InputBorder.none,
|
||||
hintText: "Search for a chat",
|
||||
hintText: I18n.of(context).searchForAChat,
|
||||
),
|
||||
)
|
||||
: Text(
|
||||
selectMode == SelectMode.share ? "Share" : "FluffyChat",
|
||||
selectMode == SelectMode.share
|
||||
? I18n.of(context).share
|
||||
: I18n.of(context).fluffychat,
|
||||
),
|
||||
leading: searchMode
|
||||
? IconButton(
|
||||
|
|
@ -166,13 +169,13 @@ class _ChatListState extends State<ChatList> {
|
|||
},
|
||||
itemBuilder: (BuildContext context) =>
|
||||
<PopupMenuEntry<String>>[
|
||||
const PopupMenuItem<String>(
|
||||
PopupMenuItem<String>(
|
||||
value: "archive",
|
||||
child: Text('Archive'),
|
||||
child: Text(I18n.of(context).archive),
|
||||
),
|
||||
const PopupMenuItem<String>(
|
||||
PopupMenuItem<String>(
|
||||
value: "settings",
|
||||
child: Text('Settings'),
|
||||
child: Text(I18n.of(context).settings),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
@ -185,7 +188,7 @@ class _ChatListState extends State<ChatList> {
|
|||
SpeedDialChild(
|
||||
child: Icon(Icons.people_outline),
|
||||
backgroundColor: Colors.blue,
|
||||
label: 'Create new group',
|
||||
label: I18n.of(context).createNewGroup,
|
||||
labelStyle: TextStyle(fontSize: 18.0),
|
||||
onTap: () => showDialog(
|
||||
context: context,
|
||||
|
|
@ -195,7 +198,7 @@ class _ChatListState extends State<ChatList> {
|
|||
SpeedDialChild(
|
||||
child: Icon(Icons.person_add),
|
||||
backgroundColor: Colors.green,
|
||||
label: 'New private chat',
|
||||
label: I18n.of(context).newPrivateChat,
|
||||
labelStyle: TextStyle(fontSize: 18.0),
|
||||
onTap: () => showDialog(
|
||||
context: context,
|
||||
|
|
@ -224,8 +227,8 @@ class _ChatListState extends State<ChatList> {
|
|||
color: Colors.grey,
|
||||
),
|
||||
Text(searchMode
|
||||
? "No rooms found..."
|
||||
: "Start your first chat :-)"),
|
||||
? I18n.of(context).noRoomsFound
|
||||
: I18n.of(context).startYourFirstChat),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:fluffychat/components/matrix.dart';
|
||||
import 'package:fluffychat/i18n/i18n.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import 'package:webview_flutter/webview_flutter.dart';
|
||||
|
|
@ -16,7 +17,7 @@ class ContentWebView extends StatelessWidget {
|
|||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
"Content viewer",
|
||||
I18n.of(context).contentViewer,
|
||||
),
|
||||
actions: <Widget>[
|
||||
IconButton(
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import 'package:famedlysdk/famedlysdk.dart';
|
|||
import 'package:fluffychat/components/adaptive_page_layout.dart';
|
||||
import 'package:fluffychat/components/avatar.dart';
|
||||
import 'package:fluffychat/components/matrix.dart';
|
||||
import 'package:fluffychat/i18n/i18n.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:toast/toast.dart';
|
||||
|
||||
|
|
@ -39,7 +40,7 @@ class InvitationSelection extends StatelessWidget {
|
|||
);
|
||||
if (success != false) {
|
||||
Toast.show(
|
||||
"Contact has been invited to the group.",
|
||||
I18n.of(context).contactHasBeenInvitedToTheGroup,
|
||||
context,
|
||||
duration: Toast.LENGTH_LONG,
|
||||
);
|
||||
|
|
@ -48,13 +49,14 @@ class InvitationSelection extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final String groupName = room.name?.isEmpty ?? false ? "group" : room.name;
|
||||
final String groupName =
|
||||
room.name?.isEmpty ?? false ? I18n.of(context).group : room.name;
|
||||
return AdaptivePageLayout(
|
||||
primaryPage: FocusPage.SECOND,
|
||||
firstScaffold: ChatList(activeChat: room.id),
|
||||
secondScaffold: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("Invite contact to $groupName"),
|
||||
title: Text(I18n.of(context).inviteContactToGroup(groupName)),
|
||||
),
|
||||
body: FutureBuilder<List<User>>(
|
||||
future: getContacts(context),
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import 'dart:math';
|
|||
|
||||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:fluffychat/components/matrix.dart';
|
||||
import 'package:fluffychat/i18n/i18n.dart';
|
||||
import 'package:fluffychat/utils/app_route.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
|
@ -26,12 +27,12 @@ class _LoginState extends State<Login> {
|
|||
void login(BuildContext context) async {
|
||||
MatrixState matrix = Matrix.of(context);
|
||||
if (usernameController.text.isEmpty) {
|
||||
setState(() => usernameError = "Please enter your username.");
|
||||
setState(() => usernameError = I18n.of(context).pleaseEnterYourUsername);
|
||||
} else {
|
||||
setState(() => usernameError = null);
|
||||
}
|
||||
if (passwordController.text.isEmpty) {
|
||||
setState(() => passwordError = "Please enter your password.");
|
||||
setState(() => passwordError = I18n.of(context).pleaseEnterYourPassword);
|
||||
} else {
|
||||
setState(() => passwordError = null);
|
||||
}
|
||||
|
|
@ -51,12 +52,13 @@ class _LoginState extends State<Login> {
|
|||
print("[Login] Check server...");
|
||||
setState(() => loading = true);
|
||||
if (!await matrix.client.checkServer(homeserver)) {
|
||||
setState(() => serverError = "Homeserver is not compatible.");
|
||||
setState(
|
||||
() => serverError = I18n.of(context).homeserverIsNotCompatible);
|
||||
|
||||
return setState(() => loading = false);
|
||||
}
|
||||
} catch (exception) {
|
||||
setState(() => serverError = "Connection attempt failed!");
|
||||
setState(() => serverError = I18n.of(context).connectionAttemptFailed);
|
||||
return setState(() => loading = false);
|
||||
}
|
||||
try {
|
||||
|
|
@ -93,6 +95,7 @@ class _LoginState extends State<Login> {
|
|||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: TextField(
|
||||
autocorrect: false,
|
||||
controller: serverController,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(Icons.domain),
|
||||
|
|
@ -125,11 +128,13 @@ class _LoginState extends State<Login> {
|
|||
child: Icon(Icons.account_box),
|
||||
),
|
||||
title: TextField(
|
||||
autocorrect: false,
|
||||
controller: usernameController,
|
||||
decoration: InputDecoration(
|
||||
hintText: "@username:domain",
|
||||
hintText:
|
||||
"@${I18n.of(context).username.toLowerCase()}:domain",
|
||||
errorText: usernameError,
|
||||
labelText: "Username"),
|
||||
labelText: I18n.of(context).username),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
|
|
@ -138,6 +143,7 @@ class _LoginState extends State<Login> {
|
|||
child: Icon(Icons.lock),
|
||||
),
|
||||
title: TextField(
|
||||
autocorrect: false,
|
||||
controller: passwordController,
|
||||
obscureText: !showPassword,
|
||||
onSubmitted: (t) => login(context),
|
||||
|
|
@ -150,7 +156,7 @@ class _LoginState extends State<Login> {
|
|||
onPressed: () =>
|
||||
setState(() => showPassword = !showPassword),
|
||||
),
|
||||
labelText: "Password"),
|
||||
labelText: I18n.of(context).password),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
|
|
@ -165,7 +171,7 @@ class _LoginState extends State<Login> {
|
|||
child: loading
|
||||
? CircularProgressIndicator()
|
||||
: Text(
|
||||
"Login",
|
||||
I18n.of(context).login,
|
||||
style: TextStyle(color: Colors.white, fontSize: 16),
|
||||
),
|
||||
onPressed: () => loading ? null : login(context),
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import 'package:famedlysdk/famedlysdk.dart';
|
|||
import 'package:fluffychat/components/adaptive_page_layout.dart';
|
||||
import 'package:fluffychat/components/content_banner.dart';
|
||||
import 'package:fluffychat/components/matrix.dart';
|
||||
import 'package:fluffychat/i18n/i18n.dart';
|
||||
import 'package:fluffychat/utils/app_route.dart';
|
||||
import 'package:fluffychat/views/chat_list.dart';
|
||||
import 'package:fluffychat/views/sign_up.dart';
|
||||
|
|
@ -47,7 +48,7 @@ class _SettingsState extends State<Settings> {
|
|||
);
|
||||
if (success != null && success.isEmpty) {
|
||||
Toast.show(
|
||||
"Displayname has been changed",
|
||||
I18n.of(context).displaynameHasBeenChanged,
|
||||
context,
|
||||
duration: Toast.LENGTH_LONG,
|
||||
);
|
||||
|
|
@ -77,7 +78,7 @@ class _SettingsState extends State<Settings> {
|
|||
print(success);
|
||||
if (success != false) {
|
||||
Toast.show(
|
||||
"Avatar has been changed",
|
||||
I18n.of(context).avatarHasBeenChanged,
|
||||
context,
|
||||
duration: Toast.LENGTH_LONG,
|
||||
);
|
||||
|
|
@ -97,7 +98,7 @@ class _SettingsState extends State<Settings> {
|
|||
});
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("Settings"),
|
||||
title: Text(I18n.of(context).settings),
|
||||
),
|
||||
body: ListView(
|
||||
children: <Widget>[
|
||||
|
|
@ -115,7 +116,7 @@ class _SettingsState extends State<Settings> {
|
|||
onSubmitted: (s) => setDisplaynameAction(context, s),
|
||||
decoration: InputDecoration(
|
||||
border: InputBorder.none,
|
||||
labelText: "Edit displayname",
|
||||
labelText: I18n.of(context).editDisplayname,
|
||||
labelStyle: TextStyle(color: Colors.black),
|
||||
hintText: (profile?.displayname ?? ""),
|
||||
),
|
||||
|
|
@ -124,7 +125,7 @@ class _SettingsState extends State<Settings> {
|
|||
Divider(thickness: 8),
|
||||
ListTile(
|
||||
title: Text(
|
||||
"About",
|
||||
I18n.of(context).about,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).primaryColor,
|
||||
fontWeight: FontWeight.bold,
|
||||
|
|
@ -132,29 +133,38 @@ class _SettingsState extends State<Settings> {
|
|||
),
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(Icons.help),
|
||||
title: Text("Help"),
|
||||
onTap: () => launch(
|
||||
"https://gitlab.com/ChristianPauly/fluffychat-flutter/issues")),
|
||||
leading: Icon(Icons.sentiment_very_satisfied),
|
||||
title: Text(I18n.of(context).donate),
|
||||
onTap: () => launch("https://ko-fi.com/krille"),
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(Icons.list),
|
||||
title: Text("Changelog"),
|
||||
onTap: () => launch(
|
||||
"https://gitlab.com/ChristianPauly/fluffychat-flutter/blob/master/CHANGELOG.md")),
|
||||
leading: Icon(Icons.help),
|
||||
title: Text(I18n.of(context).help),
|
||||
onTap: () => launch(
|
||||
"https://gitlab.com/ChristianPauly/fluffychat-flutter/issues"),
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(Icons.link),
|
||||
title: Text("License"),
|
||||
onTap: () => launch(
|
||||
"https://gitlab.com/ChristianPauly/fluffychat-flutter/raw/master/LICENSE")),
|
||||
leading: Icon(Icons.list),
|
||||
title: Text(I18n.of(context).changelog),
|
||||
onTap: () => launch(
|
||||
"https://gitlab.com/ChristianPauly/fluffychat-flutter/blob/master/CHANGELOG.md"),
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(Icons.code),
|
||||
title: Text("Source code"),
|
||||
onTap: () => launch(
|
||||
"https://gitlab.com/ChristianPauly/fluffychat-flutter")),
|
||||
leading: Icon(Icons.link),
|
||||
title: Text(I18n.of(context).license),
|
||||
onTap: () => launch(
|
||||
"https://gitlab.com/ChristianPauly/fluffychat-flutter/raw/master/LICENSE"),
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(Icons.code),
|
||||
title: Text(I18n.of(context).sourceCode),
|
||||
onTap: () =>
|
||||
launch("https://gitlab.com/ChristianPauly/fluffychat-flutter"),
|
||||
),
|
||||
Divider(thickness: 8),
|
||||
ListTile(
|
||||
title: Text(
|
||||
"Logout",
|
||||
I18n.of(context).logout,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).primaryColor,
|
||||
fontWeight: FontWeight.bold,
|
||||
|
|
@ -163,7 +173,7 @@ class _SettingsState extends State<Settings> {
|
|||
),
|
||||
ListTile(
|
||||
leading: Icon(Icons.exit_to_app),
|
||||
title: Text("Logout"),
|
||||
title: Text(I18n.of(context).logout),
|
||||
onTap: () => logoutAction(context),
|
||||
),
|
||||
],
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import 'dart:math';
|
|||
|
||||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:fluffychat/components/matrix.dart';
|
||||
import 'package:fluffychat/i18n/i18n.dart';
|
||||
import 'package:fluffychat/utils/app_route.dart';
|
||||
import 'package:fluffychat/views/login.dart';
|
||||
import 'package:fluffychat/views/sign_up_password.dart';
|
||||
|
|
@ -37,7 +38,7 @@ class _SignUpState extends State<SignUp> {
|
|||
void signUpAction(BuildContext context) async {
|
||||
MatrixState matrix = Matrix.of(context);
|
||||
if (usernameController.text.isEmpty) {
|
||||
setState(() => usernameError = "Please choose a username.");
|
||||
setState(() => usernameError = I18n.of(context).pleaseChooseAUsername);
|
||||
} else {
|
||||
setState(() => usernameError = null);
|
||||
}
|
||||
|
|
@ -60,12 +61,13 @@ class _SignUpState extends State<SignUp> {
|
|||
print("[Sign Up] Check server...");
|
||||
setState(() => loading = true);
|
||||
if (!await matrix.client.checkServer(homeserver)) {
|
||||
setState(() => serverError = "Homeserver is not compatible.");
|
||||
setState(
|
||||
() => serverError = I18n.of(context).homeserverIsNotCompatible);
|
||||
|
||||
return setState(() => loading = false);
|
||||
}
|
||||
} catch (exception) {
|
||||
setState(() => serverError = "Connection attempt failed!");
|
||||
setState(() => serverError = I18n.of(context).connectionAttemptFailed);
|
||||
return setState(() => loading = false);
|
||||
}
|
||||
|
||||
|
|
@ -94,6 +96,7 @@ class _SignUpState extends State<SignUp> {
|
|||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: TextField(
|
||||
autocorrect: false,
|
||||
controller: serverController,
|
||||
decoration: InputDecoration(
|
||||
icon: Icon(Icons.domain),
|
||||
|
|
@ -125,8 +128,9 @@ class _SignUpState extends State<SignUp> {
|
|||
Icons.close,
|
||||
color: Colors.red,
|
||||
),
|
||||
title: Text(
|
||||
avatar == null ? "Set a profile picture" : "Discard picture"),
|
||||
title: Text(avatar == null
|
||||
? I18n.of(context).setAProfilePicture
|
||||
: I18n.of(context).discardPicture),
|
||||
onTap: avatar == null
|
||||
? setAvatarAction
|
||||
: () => setState(() => avatar = null),
|
||||
|
|
@ -137,12 +141,13 @@ class _SignUpState extends State<SignUp> {
|
|||
child: Icon(Icons.account_box),
|
||||
),
|
||||
title: TextField(
|
||||
autocorrect: false,
|
||||
controller: usernameController,
|
||||
onSubmitted: (s) => signUpAction(context),
|
||||
decoration: InputDecoration(
|
||||
hintText: "Username",
|
||||
hintText: I18n.of(context).username,
|
||||
errorText: usernameError,
|
||||
labelText: "Choose a username"),
|
||||
labelText: I18n.of(context).chooseAUsername),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
|
|
@ -157,7 +162,7 @@ class _SignUpState extends State<SignUp> {
|
|||
child: loading
|
||||
? CircularProgressIndicator()
|
||||
: Text(
|
||||
"Sign up",
|
||||
I18n.of(context).signUp,
|
||||
style: TextStyle(color: Colors.white, fontSize: 16),
|
||||
),
|
||||
onPressed: () => signUpAction(context),
|
||||
|
|
@ -166,7 +171,7 @@ class _SignUpState extends State<SignUp> {
|
|||
Center(
|
||||
child: FlatButton(
|
||||
child: Text(
|
||||
"Already have an account?",
|
||||
I18n.of(context).alreadyHaveAnAccount,
|
||||
style: TextStyle(
|
||||
decoration: TextDecoration.underline,
|
||||
color: Colors.blue,
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import 'dart:math';
|
|||
|
||||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:fluffychat/components/matrix.dart';
|
||||
import 'package:fluffychat/i18n/i18n.dart';
|
||||
import 'package:fluffychat/utils/app_route.dart';
|
||||
import 'package:fluffychat/views/auth_web_view.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
|
@ -28,7 +29,7 @@ class _SignUpPasswordState extends State<SignUpPassword> {
|
|||
void _signUpAction(BuildContext context, {Map<String, dynamic> auth}) async {
|
||||
MatrixState matrix = Matrix.of(context);
|
||||
if (passwordController.text.isEmpty) {
|
||||
setState(() => passwordError = "Please enter your password.");
|
||||
setState(() => passwordError = I18n.of(context).pleaseEnterYourPassword);
|
||||
} else {
|
||||
setState(() => passwordError = null);
|
||||
}
|
||||
|
|
@ -100,7 +101,7 @@ class _SignUpPasswordState extends State<SignUpPassword> {
|
|||
data: {"displayname": widget.displayname},
|
||||
);
|
||||
} catch (exception) {
|
||||
Toast.show("Could not set displayname", context, duration: 5);
|
||||
Toast.show(I18n.of(context).couldNotSetDisplayname, context, duration: 5);
|
||||
}
|
||||
try {
|
||||
await matrix.client.setAvatar(
|
||||
|
|
@ -110,7 +111,7 @@ class _SignUpPasswordState extends State<SignUpPassword> {
|
|||
),
|
||||
);
|
||||
} catch (exception) {
|
||||
Toast.show("Could not set profile picture", context, duration: 5);
|
||||
Toast.show(I18n.of(context).couldNotSetAvatar, context, duration: 5);
|
||||
}
|
||||
if (matrix.client.isLogged()) {
|
||||
await Navigator.of(context).pushAndRemoveUntil(
|
||||
|
|
@ -123,7 +124,7 @@ class _SignUpPasswordState extends State<SignUpPassword> {
|
|||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("Secure your account with a password"),
|
||||
title: Text(I18n.of(context).secureYourAccountWithAPassword),
|
||||
),
|
||||
body: ListView(
|
||||
padding: EdgeInsets.symmetric(
|
||||
|
|
@ -161,7 +162,7 @@ class _SignUpPasswordState extends State<SignUpPassword> {
|
|||
onPressed: () =>
|
||||
setState(() => showPassword = !showPassword),
|
||||
),
|
||||
labelText: "Password"),
|
||||
labelText: I18n.of(context).password),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
|
|
@ -176,7 +177,7 @@ class _SignUpPasswordState extends State<SignUpPassword> {
|
|||
child: loading
|
||||
? CircularProgressIndicator()
|
||||
: Text(
|
||||
"Create account now",
|
||||
I18n.of(context).createAccountNow,
|
||||
style: TextStyle(color: Colors.white, fontSize: 16),
|
||||
),
|
||||
onPressed: () => loading ? null : _signUpAction(context),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue