Skip to content

Commit

Permalink
fix create group in mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
sunhuachuang committed Dec 25, 2021
1 parent a3ddf7b commit 6493411
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 22 deletions.
30 changes: 18 additions & 12 deletions lib/apps/group/add.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,24 @@ class _GroupAddScreenState extends State<GroupAddScreen> {
_send(String name, bool isDesktop) async {
final res = await httpPost('group-create', [name]);
if (res.isOk) {
print(res.params);
final id = res.params[0];
final w = GroupChatDetail(id: id);
if (w != null) {
if (isDesktop) {
Provider.of<AccountProvider>(context, listen: false).updateActivedWidget(w);
rpc.send('group-member-join', [id, widget.fid]);
} else {
Navigator.push(context, MaterialPageRoute(builder: (_) => w));
}
}
Navigator.pop(context);
// use delayed because waiting this session added.
Future.delayed(Duration(seconds: 1), () async {
final fid = widget.fid;
Navigator.pop(context);
final sid = res.params[0];
final id = res.params[1];
final w = GroupChatDetail(id: id);
rpc.send('group-member-join', [id, fid]);
Provider.of<AccountProvider>(context, listen: false).updateActivedSession(sid);
if (w != null) {
if (isDesktop) {
Provider.of<AccountProvider>(context, listen: false).updateActivedWidget(w);
} else {
Navigator.pop(context);
Navigator.push(context, MaterialPageRoute(builder: (_) => w));
}
}
});
} else {
setState(() {
this._error = res.error;
Expand Down
4 changes: 2 additions & 2 deletions lib/apps/group/detail.dart
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,8 @@ class _GroupChatDetailState extends State<GroupChatDetail> {
final msg = this._messages[recentMessageKeys[index]]!;
return ChatMessage(
avatar: this._members[msg.mid]!.showAvatar(isOnline: false),
fgid: this._group.gid,
name: this._group.name,
fgid: this._members[msg.mid]!.mid,
name: this._members[msg.mid]!.name,
message: msg,
);
}
Expand Down
8 changes: 4 additions & 4 deletions lib/apps/wallet/page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ class _WalletDetailState extends State<WalletDetail> with SingleTickerProviderSt
children: [
const Icon(Icons.lock),
const SizedBox(width: 8.0),
const Text('生成以太坊地址'),
Text(lang.walletGenerate),
]
)
)
Expand Down Expand Up @@ -478,7 +478,7 @@ class _WalletDetailState extends State<WalletDetail> with SingleTickerProviderSt
unselectedLabelColor: color.onSurface,
labelColor: Color(0xFF6174FF),
tabs: [
Tab(text: 'Assets'),
Tab(text: 'Tokens'),
Tab(text: 'Activity'),
],
controller: _tabController!,
Expand All @@ -496,7 +496,7 @@ class _WalletDetailState extends State<WalletDetail> with SingleTickerProviderSt
return TextButton(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 10.0),
child: Text('Add new Token' + ' ( ERC20 / ERC721 )')
child: Text('Add Token' + ' ( ERC20 / ERC721 )')
),
onPressed: () => showShadowDialog(
context, Icons.paid, 'Token', _ImportToken(
Expand Down Expand Up @@ -982,7 +982,7 @@ class _TransferTokenState extends State<_TransferToken> {
children: [
const SizedBox(width: 10.0),
TextButton(child: Text(
this._myAccount ? 'Input Account' : 'Between Accounts'
this._myAccount ? lang.walletInputAccount: lang.walletBetweenAccount,
), onPressed: () => setState(() {
this._myAccount = !this._myAccount;
if (this._selectAddress.length == 0) {
Expand Down
3 changes: 3 additions & 0 deletions lib/l10n/localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,9 @@ abstract class AppLocalizations {

String get wallet;
String get walletIntro;
String get walletGenerate;
String get walletInputAccount;
String get walletBetweenAccount;
String get secretKey;
String get contract;
String get main;
Expand Down
6 changes: 6 additions & 0 deletions lib/l10n/localizations_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,12 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get walletIntro => 'Manage your own cryptocurrency.';
@override
String get walletGenerate => 'Generate ETH account';
@override
String get walletInputAccount => 'Input Account';
@override
String get walletBetweenAccount => 'Between Accounts';
@override
String get secretKey => 'Secret Key';
@override
String get contract => 'Contract Address';
Expand Down
6 changes: 6 additions & 0 deletions lib/l10n/localizations_zh.dart
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,12 @@ class AppLocalizationsZh extends AppLocalizations {
@override
String get walletIntro => '管理自己的加密货币。';
@override
String get walletGenerate => '生成以太坊地址';
@override
String get walletInputAccount => '输入对方账号';
@override
String get walletBetweenAccount => '自己账户之间';
@override
String get secretKey => '私钥';
@override
String get contract => '合约地址';
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/chat_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ class ChatMessage extends StatelessWidget {
if (message.isMe) Spacer(),
if (isAvatar)
Container(
width: 50.0,
width: 60.0,
child: Text(name, maxLines: 1, overflow: TextOverflow.ellipsis,
style: TextStyle(color: color.onPrimary.withOpacity(0.5), fontSize: 10.0)
)),
Expand Down
6 changes: 3 additions & 3 deletions src/apps/group/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,6 @@ pub(crate) fn new_rpc_handler(handler: &mut RpcHandler<RpcState>) {

let mut results = HandleResult::new();

// add to rpcs.
results.rpcs.push(json!(gc.to_rpc()));

let mut m = Member::new(gheight, gc.id, gid, me.addr, me.name);
m.insert(&db)?;
let mid = m.id;
Expand All @@ -143,6 +140,9 @@ pub(crate) fn new_rpc_handler(handler: &mut RpcHandler<RpcState>) {
.await;
});

// add to rpcs.
results.rpcs.push(json!([sid, gdid]));

// Add frist member join.
let mut layer_lock = state.layer.write().await;
layer_lock.add_running(&gcd, gid, gdid, gheight)?;
Expand Down
1 change: 1 addition & 0 deletions src/primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pub(crate) fn network_seeds() -> Vec<Peer> {
#[rustfmt::skip]
let seeds: Vec<(&str, &str)> = vec![
("1.15.156.199:7364", "quic"),
("184.170.220.231:7364", "quic"),
];

seeds
Expand Down

0 comments on commit 6493411

Please sign in to comment.