Browse Source

fix create group chat UI

pull/18/head
Sun 4 years ago
parent
commit
5902a47844
  1. 21
      lib/apps/group_chat/add.dart
  2. 3
      lib/apps/group_chat/models.dart
  3. 23
      lib/apps/group_chat/provider.dart
  4. 1
      src/storage.rs

21
lib/apps/group_chat/add.dart

@ -51,8 +51,6 @@ class _GroupAddPageState extends State<GroupAddPage> { @@ -51,8 +51,6 @@ class _GroupAddPageState extends State<GroupAddPage> {
int _groupAddr = 0;
int _groupType = 1;
bool _groupNeedAgree = false;
bool _groupHasKey = true;
bool _groupHasNeedAgree = true;
bool _addrOnline = false;
bool _addrChecked = false;
String _myName = '';
@ -87,17 +85,6 @@ class _GroupAddPageState extends State<GroupAddPage> { @@ -87,17 +85,6 @@ class _GroupAddPageState extends State<GroupAddPage> {
groupValue: _groupType,
onChanged: disabled ? null : (n) => setState(() {
_groupType = n;
if (n == 0) {
_groupHasKey = true;
} else {
_groupHasKey = false;
}
if (n == 2) {
_groupHasNeedAgree = false;
} else {
_groupHasNeedAgree = true;
}
}),
),
_groupType == value
@ -117,7 +104,7 @@ class _GroupAddPageState extends State<GroupAddPage> { @@ -117,7 +104,7 @@ class _GroupAddPageState extends State<GroupAddPage> {
if (addr.substring(0, 2) == '0x') {
addr = addr.substring(2);
}
rpc.send('group-chat-check', [addr]);
context.read<GroupChatProvider>().check(addr);
}
_scanCallback(bool isOk, String app, List params) {
@ -203,6 +190,8 @@ class _GroupAddPageState extends State<GroupAddPage> { @@ -203,6 +190,8 @@ class _GroupAddPageState extends State<GroupAddPage> {
rpc.send('group-chat-request-list', [false]);
new Future.delayed(Duration.zero, () {
_myName = context.read<AccountProvider>().activedAccount.name;
context.read<GroupChatProvider>().clearCheck();
setState(() {});
});
}
@ -488,7 +477,7 @@ class _GroupAddPageState extends State<GroupAddPage> { @@ -488,7 +477,7 @@ class _GroupAddPageState extends State<GroupAddPage> {
controller: _createBioController,
focus: _createBioFocus),
),
if (_groupHasKey)
if (_groupType == 0)
Container(
padding: EdgeInsets.symmetric(vertical: 10.0),
child: InputText(
@ -497,7 +486,7 @@ class _GroupAddPageState extends State<GroupAddPage> { @@ -497,7 +486,7 @@ class _GroupAddPageState extends State<GroupAddPage> {
controller: _createKeyController,
focus: _createKeyFocus),
),
if (_groupHasNeedAgree)
if (_groupType != 2)
Container(
height: 50.0,
width: 600.0,

3
lib/apps/group_chat/models.dart

@ -19,6 +19,7 @@ enum CheckType { @@ -19,6 +19,7 @@ enum CheckType {
Suspend,
Deny,
Wait,
Nothing,
}
extension GroupTypeExtension on GroupType {
@ -87,7 +88,7 @@ extension CheckTypeExtension on CheckType { @@ -87,7 +88,7 @@ extension CheckTypeExtension on CheckType {
case 3:
return CheckType.Deny;
default:
return CheckType.Deny;
return CheckType.Nothing;
}
}
}

23
lib/apps/group_chat/provider.dart

@ -10,7 +10,7 @@ import 'package:esse/apps/group_chat/models.dart'; @@ -10,7 +10,7 @@ import 'package:esse/apps/group_chat/models.dart';
class GroupChatProvider extends ChangeNotifier {
List<GroupType> createSupported = [GroupType.Encrypted, GroupType.Private, GroupType.Open];
CheckType createCheckType = CheckType.Wait;
CheckType createCheckType = CheckType.Nothing;
Map<int, GroupChat> groups = {};
List<int> createKeys = [];
@ -122,6 +122,15 @@ class GroupChatProvider extends ChangeNotifier { @@ -122,6 +122,15 @@ class GroupChatProvider extends ChangeNotifier {
this.requests.clear();
}
check(String addr) {
this.createCheckType = CheckType.Wait;
rpc.send('group-chat-check', [addr]);
}
clearCheck() {
this.createCheckType = CheckType.Nothing;
}
join(GroupType gtype, String gid, String gaddr, String name, String remark, [String proof = '', String key = '']) {
rpc.send('group-chat-join', [gtype.toInt(), gid, gaddr, name, remark, proof, key]);
}
@ -185,11 +194,13 @@ class GroupChatProvider extends ChangeNotifier { @@ -185,11 +194,13 @@ class GroupChatProvider extends ChangeNotifier {
_check(List params) {
this.createSupported.clear();
this.createCheckType = CheckTypeExtension.fromInt(params[0]);
params[1].forEach((param) {
this.createSupported.add(GroupTypeExtension.fromInt(param));
});
notifyListeners();
if (this.createCheckType == CheckType.Wait) {
this.createCheckType = CheckTypeExtension.fromInt(params[0]);
params[1].forEach((param) {
this.createSupported.add(GroupTypeExtension.fromInt(param));
});
notifyListeners();
}
}
_create(List params) {

1
src/storage.rs

@ -2,7 +2,6 @@ use async_fs as fs; @@ -2,7 +2,6 @@ use async_fs as fs;
use image::{load_from_memory, DynamicImage, GenericImageView};
use rand::{distributions::Alphanumeric, thread_rng, Rng};
use std::path::PathBuf;
use std::sync::Arc;
use std::time::{SystemTime, UNIX_EPOCH};
use tdn::types::{

Loading…
Cancel
Save