@ -33,11 +33,9 @@ class GroupAddPage extends StatefulWidget {
class _GroupAddPageState extends State < GroupAddPage > {
class _GroupAddPageState extends State < GroupAddPage > {
TextEditingController _joinIdController = TextEditingController ( ) ;
TextEditingController _joinIdController = TextEditingController ( ) ;
TextEditingController _joinAddrController = TextEditingController ( ) ;
TextEditingController _joinAddrController = TextEditingController ( ) ;
TextEditingController _joinRemarkController = TextEditingController ( ) ;
TextEditingController _joinNameController = TextEditingController ( ) ;
TextEditingController _joinNameController = TextEditingController ( ) ;
FocusNode _joinIdFocus = FocusNode ( ) ;
FocusNode _joinIdFocus = FocusNode ( ) ;
FocusNode _joinAddrFocus = FocusNode ( ) ;
FocusNode _joinAddrFocus = FocusNode ( ) ;
FocusNode _joinRemarkFocus = FocusNode ( ) ;
TextEditingController _createAddrController = TextEditingController ( ) ;
TextEditingController _createAddrController = TextEditingController ( ) ;
TextEditingController _createNameController = TextEditingController ( ) ;
TextEditingController _createNameController = TextEditingController ( ) ;
@ -47,6 +45,8 @@ class _GroupAddPageState extends State<GroupAddPage> {
FocusNode _createNameFocus = FocusNode ( ) ;
FocusNode _createNameFocus = FocusNode ( ) ;
FocusNode _createBioFocus = FocusNode ( ) ;
FocusNode _createBioFocus = FocusNode ( ) ;
FocusNode _createKeyFocus = FocusNode ( ) ;
FocusNode _createKeyFocus = FocusNode ( ) ;
int _groupAddr = 0 ;
int _groupType = 0 ;
int _groupType = 0 ;
bool _groupNeedAgree = false ;
bool _groupNeedAgree = false ;
bool _groupHasKey = true ;
bool _groupHasKey = true ;
@ -57,6 +57,24 @@ class _GroupAddPageState extends State<GroupAddPage> {
bool _requestsLoadMore = true ;
bool _requestsLoadMore = true ;
/ / 0 = > encrypted , 1 = > common , 2 = > open .
Widget _groupAddrWidget ( String text , int value , ColorScheme color ) {
return Row (
children: [
Radio (
value: value ,
groupValue: _groupAddr ,
onChanged: ( n ) = > setState ( ( ) {
_groupAddr = n ;
} ) ,
) ,
_groupAddr = = value
? Text ( text , style: TextStyle ( color: color . primary ) )
: Text ( text ) ,
]
) ;
}
/ / 0 = > encrypted , 1 = > common , 2 = > open .
/ / 0 = > encrypted , 1 = > common , 2 = > open .
Widget _groupTypeWidget ( String text , int value , ColorScheme color ) {
Widget _groupTypeWidget ( String text , int value , ColorScheme color ) {
return Row (
return Row (
@ -126,13 +144,11 @@ class _GroupAddPageState extends State<GroupAddPage> {
addr = addr . substring ( 2 ) ;
addr = addr . substring ( 2 ) ;
}
}
var name = _joinNameController . text ;
var name = _joinNameController . text ;
var remark = _joinRemarkController . text ;
context . read < GroupChatProvider > ( ) . join ( id , addr , name , " " ) ;
context . read < GroupChatProvider > ( ) . join ( id , addr , name , remark ) ;
setState ( ( ) {
setState ( ( ) {
_joinIdController . text = ' ' ;
_joinIdController . text = ' ' ;
_joinAddrController . text = ' ' ;
_joinAddrController . text = ' ' ;
_joinNameController . text = ' ' ;
_joinNameController . text = ' ' ;
_joinRemarkController . text = ' ' ;
} ) ;
} ) ;
}
}
@ -167,9 +183,6 @@ class _GroupAddPageState extends State<GroupAddPage> {
_joinAddrFocus . addListener ( ( ) {
_joinAddrFocus . addListener ( ( ) {
setState ( ( ) { } ) ;
setState ( ( ) { } ) ;
} ) ;
} ) ;
_joinRemarkFocus . addListener ( ( ) {
setState ( ( ) { } ) ;
} ) ;
_createAddrFocus . addListener ( ( ) {
_createAddrFocus . addListener ( ( ) {
setState ( ( ) { } ) ;
setState ( ( ) { } ) ;
} ) ;
} ) ;
@ -214,7 +227,7 @@ class _GroupAddPageState extends State<GroupAddPage> {
title: Row (
title: Row (
children: [
children: [
Expanded (
Expanded (
child: Text ( ' Add Group Chat ' ,
child: Text ( lang . groupChatAdd ,
style: TextStyle ( fontWeight: FontWeight . bold , fontSize: 20.0 ) ) ,
style: TextStyle ( fontWeight: FontWeight . bold , fontSize: 20.0 ) ) ,
) ,
) ,
TextButton (
TextButton (
@ -233,7 +246,7 @@ class _GroupAddPageState extends State<GroupAddPage> {
children: [
children: [
Icon ( Icons . add_box_rounded , color: color . primary ) ,
Icon ( Icons . add_box_rounded , color: color . primary ) ,
const SizedBox ( width: 8.0 ) ,
const SizedBox ( width: 8.0 ) ,
Text ( ' Join A Group ' , style: TextStyle ( color: color . primary ) )
Text ( lang . groupJoin , style: TextStyle ( color: color . primary ) )
] )
] )
) ,
) ,
Tab (
Tab (
@ -242,7 +255,7 @@ class _GroupAddPageState extends State<GroupAddPage> {
children: [
children: [
Icon ( Icons . create_rounded , color: color . primary ) ,
Icon ( Icons . create_rounded , color: color . primary ) ,
const SizedBox ( width: 8.0 ) ,
const SizedBox ( width: 8.0 ) ,
Text ( ' Create A Group ' , style: TextStyle ( color: color . primary ) )
Text ( lang . groupCreate , style: TextStyle ( color: color . primary ) )
] )
] )
) ,
) ,
] ,
] ,
@ -253,226 +266,265 @@ class _GroupAddPageState extends State<GroupAddPage> {
Container (
Container (
padding: const EdgeInsets . all ( 20 ) ,
padding: const EdgeInsets . all ( 20 ) ,
child: SingleChildScrollView (
child: SingleChildScrollView (
child: Form (
child: Column (
child: Column (
crossAxisAlignment: CrossAxisAlignment . center ,
crossAxisAlignment: CrossAxisAlignment . center ,
children: < Widget > [
children: < Widget > [
const SizedBox ( height: 20.0 ) ,
InputText (
InputText (
icon: Icons . groups ,
icon: Icons . groups ,
text: ' Group ID ' ,
text: lang . groupChatId ,
controller: _joinIdController ,
controller: _joinIdController ,
focus: _joinIdFocus ) ,
focus: _joinIdFocus ) ,
const SizedBox ( height: 20.0 ) ,
const SizedBox ( height: 20.0 ) ,
InputText (
InputText (
icon: Icons . location_on ,
icon: Icons . location_on ,
text: lang . groupChatAddr ,
text: lang . address ,
controller: _joinAddrController ,
controller: _joinAddrController ,
focus: _joinAddrFocus ) ,
focus: _joinAddrFocus ) ,
const SizedBox ( height: 20.0 ) ,
const SizedBox ( height: 20.0 ) ,
ButtonText ( action: _join , text: lang . send , width: 600.0 ) ,
InputText (
const SizedBox ( height: 20.0 ) ,
icon: Icons . turned_in ,
const Divider ( height: 1.0 , color: Color ( 0x40ADB0BB ) ) ,
text: lang . remark ,
const SizedBox ( height: 10.0 ) ,
controller: _joinRemarkController ,
if ( requests . isNotEmpty )
focus: _joinRemarkFocus ) ,
Container (
const SizedBox ( height: 20.0 ) ,
width: 600.0 ,
ButtonText ( action: _join , text: lang . send , width: 600.0 ) ,
child: ListView . builder (
const SizedBox ( height: 20.0 ) ,
itemCount: requestKeys . length ,
const Divider ( height: 1.0 , color: Color ( 0x40ADB0BB ) ) ,
shrinkWrap: true ,
const SizedBox ( height: 10.0 ) ,
physics: ClampingScrollPhysics ( ) ,
if ( requests . isNotEmpty )
scrollDirection: Axis . vertical ,
Container (
itemBuilder: ( BuildContext context , int index ) = >
width: 600.0 ,
_RequestItem ( request: requests [ requestKeys [ index ] ] ) ,
child: ListView . builder (
itemCount: requestKeys . length ,
shrinkWrap: true ,
physics: ClampingScrollPhysics ( ) ,
scrollDirection: Axis . vertical ,
itemBuilder: ( BuildContext context , int index ) = >
_RequestItem ( request: requests [ requestKeys [ index ] ] ) ,
) ,
) ,
) ,
if ( _requestsLoadMore )
) ,
TextButton (
if ( _requestsLoadMore )
onPressed: ( ) {
TextButton (
provider . requestList ( true ) ;
onPressed: ( ) {
setState ( ( ) {
provider . requestList ( true ) ;
_requestsLoadMore = false ;
setState ( ( ) {
} ) ;
_requestsLoadMore = false ;
} ,
} ) ;
child: Text ( ' load more... ' , style: TextStyle ( fontSize: 14.0 ) ) ,
} ,
) ,
child: Text ( lang . loadMore , style: TextStyle ( fontSize: 14.0 ) ) ,
] ,
) ,
) ,
] ,
) ,
) ,
) ,
) ,
) ,
) ,
Container (
Container (
padding: const EdgeInsets . all ( 20 ) ,
padding: const EdgeInsets . all ( 20 ) ,
child: SingleChildScrollView (
child: SingleChildScrollView (
child: Form (
child: Column (
child: Column (
crossAxisAlignment: CrossAxisAlignment . center ,
crossAxisAlignment: CrossAxisAlignment . center ,
children: < Widget > [
children: < Widget > [
Container (
Container (
width: 600.0 ,
height: 50.0 ,
padding: const EdgeInsets . all ( 10.0 ) ,
width: 600.0 ,
alignment: Alignment . centerLeft ,
child: Row (
child: Text ( ' 1. ' + lang . groupChatAddr , textAlign: TextAlign . left ,
children: [
style: Theme . of ( context ) . textTheme . title ) ,
Expanded (
) ,
child: Container (
Container (
padding: const EdgeInsets . symmetric ( horizontal: 20.0 ) ,
padding: EdgeInsets . only ( bottom: 10.0 ) ,
decoration: BoxDecoration (
width: 600.0 ,
color: color . surface ,
child: Row (
border: Border . all ( color: _createAddrFocus . hasFocus
mainAxisSize: MainAxisSize . max ,
? color . primary : color . surface ) ,
mainAxisAlignment: MainAxisAlignment . spaceEvenly ,
borderRadius: BorderRadius . circular ( 15.0 ) ,
children: [
) ,
_groupAddrWidget ( lang . deviceRemote , 0 , color ) ,
child: TextField (
_groupAddrWidget ( lang . deviceLocal , 1 , color ) ,
style: TextStyle ( fontSize: 16.0 ) ,
]
decoration: InputDecoration (
)
border: InputBorder . none ,
) ,
hintText: lang . address ) ,
if ( _groupAddr = = 0 )
controller: _createAddrController ,
Container (
focusNode: _createAddrFocus ,
height: 50.0 ,
onSubmitted: ( _v ) = > _checkAddrPermission ( ) ,
width: 600.0 ,
onChanged: ( v ) {
child: Row (
if ( v . length > 0 ) {
children: [
setState ( ( ) {
Expanded (
_addrChecked = true ;
child: Container (
} ) ;
padding: const EdgeInsets . symmetric ( horizontal: 20.0 ) ,
}
decoration: BoxDecoration (
} ) ,
color: color . surface ,
border: Border . all ( color: _createAddrFocus . hasFocus
? color . primary : color . surface ) ,
borderRadius: BorderRadius . circular ( 15.0 ) ,
) ,
) ,
child: TextField (
style: TextStyle ( fontSize: 16.0 ) ,
decoration: InputDecoration (
border: InputBorder . none ,
hintText: lang . address ) ,
controller: _createAddrController ,
focusNode: _createAddrFocus ,
onSubmitted: ( _v ) = > _checkAddrPermission ( ) ,
onChanged: ( v ) {
if ( v . length > 0 ) {
setState ( ( ) {
_addrChecked = true ;
} ) ;
}
} ) ,
) ,
) ,
if ( checkOk )
) ,
Container (
if ( checkOk )
padding: const EdgeInsets . only ( left: 8.0 ) ,
Container (
child: Icon ( Icons . cloud_done_rounded ,
padding: const EdgeInsets . only ( left: 8.0 ) ,
color: Colors . green ) ,
child: Icon ( Icons . cloud_done_rounded ,
) ,
color: Colors . green ) ,
const SizedBox ( width: 8.0 ) ,
) ,
Container (
const SizedBox ( width: 8.0 ) ,
width: 100.0 ,
InkWell (
child: InkWell (
onTap: _addrChecked ? _checkGroupAddr : null ,
onTap: _addrChecked ? _checkGroupAddr : null ,
child: Container (
child: Container (
padding: const EdgeInsets . symmetric ( horizontal: 20.0 ) ,
height: 45.0 ,
height: 45.0 ,
decoration: BoxDecoration (
decoration: BoxDecoration (
color: Color ( 0xFF6174FF ) ,
color: Color ( 0xFF6174FF ) ,
borderRadius: BorderRadius . circular ( 15.0 ) ) ,
borderRadius: BorderRadius . circular ( 15.0 ) ) ,
child: Center (
child: Center (
child: Text ( lang . search ,
child: Text ( lang . search ,
style: TextStyle ( fontSize: 16.0 , color: Colors . white ) ) ) ,
style: TextStyle ( fontSize: 16.0 , color: Colors . white ) ) ) ,
) ) ) ,
) ) ,
] ) ) ,
const SizedBox ( width: 8.0 ) ,
const SizedBox ( height: 8.0 ) ,
InkWell (
Text ( checkLang , style: TextStyle ( fontSize: 14.0 ,
onTap: _addrChecked ? _checkGroupAddr : null ,
color: checkOk ? Colors . green : Colors . red ) ) ,
child: Container (
Container (
padding: const EdgeInsets . symmetric ( horizontal: 20.0 ) ,
width: 600 .0,
height: 45 .0 ,
padding: const EdgeInsets . all ( 10.0 ) ,
decoration: BoxDecoration (
alignment: Alignment . centerLeft ,
color: Color ( 0xFF6174FF ) ,
child: Text ( ' Group Info ' , textAlign: TextAlign . left , style: TextStyle ( fontSize: 20.0 , fontWeight: FontWeight . bold ) ) ,
borderRadius: BorderRadius . circular ( 15.0 ) ) ,
) ,
child: Center (
Container (
child: Text ( lang . add ,
width: 100.0 ,
style: TextStyle ( fontSize: 16.0 , color: Colors . white ) ) ) ,
height: 100.0 ,
) ) ,
margin: const EdgeInsets . symmetric ( vertical: 10.0 ) ,
] ) ) ,
decoration: BoxDecoration (
const SizedBox ( height: 8.0 ) ,
color: color . surface ,
Text ( checkLang , style: TextStyle ( fontSize: 14.0 ,
borderRadius: BorderRadius . circular ( 15.0 ) ) ,
color: checkOk ? Colors . green : Colors . red ) ) ,
child: Stack (
Container (
alignment: Alignment . center ,
width: 600.0 ,
children: < Widget > [
padding: const EdgeInsets . all ( 10.0 ) ,
Icon ( Icons . camera_al t ,
alignment: Alignment . centerLef t,
size: 47.0 , color: Color ( 0xFFADB0BB ) ) ,
child: Text ( ' 2. ' + lang . groupChatInfo , textAlign: TextAlign . left ,
Positioned (
style: Theme . of ( context ) . textTheme . title ) ,
bottom: - 1.0 ,
) ,
right: - 1.0 ,
Container (
child: InkWell (
width: 100.0 ,
child: Icon ( Icons . add_circle ,
height: 100.0 ,
size: 32.0 , color: color . primary ) ,
margin: const EdgeInsets . symmetric ( vertical: 10.0 ) ,
onTap: null , / / ( ) = > _getImage ( context , account . name , color , lang ) ,
decoration: BoxDecoration (
)
color: color . surface ,
) ,
borderRadius: BorderRadius . circular ( 15.0 ) ) ,
] ,
child: Stack (
) ,
alignment: Alignment . center ,
) ,
children: < Widget > [
Container (
Icon ( Icons . camera_alt ,
padding: EdgeInsets . symmetric ( vertical: 10.0 ) ,
size: 47.0 , color: Color ( 0xFFADB0BB ) ) ,
width: 600.0 ,
Positioned (
child: Row (
bottom: - 1.0 ,
mainAxisSize: MainAxisSize . max ,
right: - 1.0 ,
mainAxisAlignment: MainAxisAlignment . spaceEvenly ,
child: InkWell (
children: [
child: Icon ( Icons . add_circle ,
_groupTypeWidget ( ' Encrypted ' , 0 , color ) ,
size: 32.0 , color: color . primary ) ,
_groupTypeWidget ( ' Common ' , 1 , color ) ,
onTap: null , / / ( ) = > _getImage ( context , account . name , color , lang ) ,
_groupTypeWidget ( ' Open ' , 2 , color ) ,
)
]
) ,
)
] ,
) ,
) ,
Container (
) ,
padding: EdgeInsets . symmetric ( vertical: 10.0 ) ,
Container (
child: InputText (
padding: EdgeInsets . symmetric ( vertical: 10.0 ) ,
icon: Icons . account_box ,
width: 600.0 ,
text: ' Group Name ' ,
child: Row (
controller: _createNameController ,
mainAxisSize: MainAxisSize . max ,
focus: _createNameFocus ) ,
mainAxisAlignment: MainAxisAlignment . spaceEvenly ,
children: [
_groupTypeWidget ( lang . groupTypeEncrypted , 0 , color ) ,
_groupTypeWidget ( lang . groupTypePrivate , 1 , color ) ,
_groupTypeWidget ( lang . groupTypeOpen , 2 , color ) ,
]
)
) ,
Container (
width: 600.0 ,
padding: const EdgeInsets . all ( 12.0 ) ,
margin: const EdgeInsets . only ( bottom: 10.0 ) ,
decoration: BoxDecoration ( color: color . surface ,
borderRadius: BorderRadius . circular ( 15.0 )
) ,
) ,
Container (
child: Text (
padding: EdgeInsets . symmetric ( vertical: 10.0 ) ,
_groupType = = 0 ? lang . groupTypeEncryptedInfo
child: InputText (
: ( _groupType = = 1 ? lang . groupTypePrivateInfo
icon: Icons . campaign ,
: lang . groupTypeOpenInfo ) ,
text: ' Group Bio ' ,
style: TextStyle ( fontSize: 14.0 , height: 1.5 ,
controller: _createBioController ,
fontStyle: FontStyle . italic ) ,
focus: _createBioFocus ) ,
textAlign: TextAlign . center ,
) ,
) ,
if ( _groupHasKey )
) ,
Container (
Container (
padding: EdgeInsets . symmetric ( vertical: 10.0 ) ,
padding: EdgeInsets . symmetric ( vertical: 10.0 ) ,
child: InputText (
child: InputText (
icon: Icons . enhanced_encryption ,
icon: Icons . account_box ,
text: ' Encrypted Key ' ,
text: lang . groupChatName ,
controller: _createKeyController ,
controller: _createNameController ,
focus: _createKeyFocus ) ,
focus: _createNameFocus ) ,
) ,
Container (
padding: EdgeInsets . symmetric ( vertical: 10.0 ) ,
child: InputText (
icon: Icons . campaign ,
text: lang . groupChatBio ,
controller: _createBioController ,
focus: _createBioFocus ) ,
) ,
if ( _groupHasKey )
Container (
padding: EdgeInsets . symmetric ( vertical: 10.0 ) ,
child: InputText (
icon: Icons . enhanced_encryption ,
text: lang . groupChatKey ,
controller: _createKeyController ,
focus: _createKeyFocus ) ,
) ,
if ( _groupHasNeedAgree )
Container (
height: 50.0 ,
width: 600.0 ,
child: Row (
children: [
Switch (
value: _groupNeedAgree ,
onChanged: ( value ) {
setState ( ( ) {
_groupNeedAgree = value ;
} ) ;
} ,
) ,
Text ( lang . groupRequireConsent )
]
) ,
) ,
if ( _groupHasNeedAgree )
) ,
Container (
const SizedBox ( height: 20.0 ) ,
height: 50.0 ,
ButtonText ( action: _create , text: lang . create , width: 600.0 ) ,
width: 600.0 ,
const SizedBox ( height: 20.0 ) ,
child: Row (
const Divider ( height: 1.0 , color: Color ( 0x40ADB0BB ) ) ,
children: [
const SizedBox ( height: 10.0 ) ,
Switch (
Container (
value: _groupNeedAgree ,
width: 600.0 ,
onChanged: ( value ) {
child: ListView . builder (
setState ( ( ) {
itemCount: createKeys . length ,
_groupNeedAgree = value ;
shrinkWrap: true ,
} ) ;
physics: ClampingScrollPhysics ( ) ,
} ,
scrollDirection: Axis . vertical ,
) ,
itemBuilder: ( BuildContext context , int index ) = >
Text ( ' Need Group Manager Agree. ' )
_CreateItem ( group: groups [ createKeys [ index ] ] , name: _myName ) ,
]
) ,
) ,
) ,
const SizedBox ( height: 20.0 ) ,
)
ButtonText ( action: _create , text: lang . create , width: 600.0 ) ,
] ,
const SizedBox ( height: 20.0 ) ,
const Divider ( height: 1.0 , color: Color ( 0x40ADB0BB ) ) ,
const SizedBox ( height: 10.0 ) ,
Container (
width: 600.0 ,
child: ListView . builder (
itemCount: createKeys . length ,
shrinkWrap: true ,
physics: ClampingScrollPhysics ( ) ,
scrollDirection: Axis . vertical ,
itemBuilder: ( BuildContext context , int index ) = >
_CreateItem ( group: groups [ createKeys [ index ] ] , name: _myName ) ,
) ,
)
] ,
) ,
) ,
) ,
) ,
) ,
) ,
) ,