Browse Source

fix create group in mobile

pull/18/head
Sun 4 years ago
parent
commit
64934111e1
  1. 30
      lib/apps/group/add.dart
  2. 4
      lib/apps/group/detail.dart
  3. 8
      lib/apps/wallet/page.dart
  4. 3
      lib/l10n/localizations.dart
  5. 6
      lib/l10n/localizations_en.dart
  6. 6
      lib/l10n/localizations_zh.dart
  7. 2
      lib/widgets/chat_message.dart
  8. 6
      src/apps/group/rpc.rs
  9. 1
      src/primitives.rs

30
lib/apps/group/add.dart

@ -38,18 +38,24 @@ class _GroupAddScreenState extends State<GroupAddScreen> { @@ -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;

4
lib/apps/group/detail.dart

@ -289,8 +289,8 @@ class _GroupChatDetailState extends State<GroupChatDetail> { @@ -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,
);
}

8
lib/apps/wallet/page.dart

@ -211,7 +211,7 @@ class _WalletDetailState extends State<WalletDetail> with SingleTickerProviderSt @@ -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),
]
)
)
@ -478,7 +478,7 @@ class _WalletDetailState extends State<WalletDetail> with SingleTickerProviderSt @@ -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!,
@ -496,7 +496,7 @@ class _WalletDetailState extends State<WalletDetail> with SingleTickerProviderSt @@ -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(
@ -982,7 +982,7 @@ class _TransferTokenState extends State<_TransferToken> { @@ -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) {

3
lib/l10n/localizations.dart

@ -267,6 +267,9 @@ abstract class AppLocalizations { @@ -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;

6
lib/l10n/localizations_en.dart

@ -438,6 +438,12 @@ class AppLocalizationsEn extends AppLocalizations { @@ -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';

6
lib/l10n/localizations_zh.dart

@ -438,6 +438,12 @@ class AppLocalizationsZh extends AppLocalizations { @@ -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 => '合约地址';

2
lib/widgets/chat_message.dart

@ -323,7 +323,7 @@ class ChatMessage extends StatelessWidget { @@ -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)
)),

6
src/apps/group/rpc.rs

@ -124,9 +124,6 @@ pub(crate) fn new_rpc_handler(handler: &mut RpcHandler<RpcState>) { @@ -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;
@ -143,6 +140,9 @@ pub(crate) fn new_rpc_handler(handler: &mut RpcHandler<RpcState>) { @@ -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)?;

1
src/primitives.rs

@ -5,6 +5,7 @@ pub(crate) fn network_seeds() -> Vec<Peer> { @@ -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

Loading…
Cancel
Save