@ -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,29 +266,22 @@ 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 . address ,
text: lang . groupCh atA ddr,
controller: _joinAddrController ,
controller: _joinAddrController ,
focus: _joinAddrFocus ) ,
focus: _joinAddrFocus ) ,
const SizedBox ( height: 20.0 ) ,
const SizedBox ( height: 20.0 ) ,
InputText (
icon: Icons . turned_in ,
text: lang . remark ,
controller: _joinRemarkController ,
focus: _joinRemarkFocus ) ,
const SizedBox ( height: 20.0 ) ,
ButtonText ( action: _join , text: lang . send , width: 600.0 ) ,
ButtonText ( action: _join , text: lang . send , width: 600.0 ) ,
const SizedBox ( height: 20.0 ) ,
const SizedBox ( height: 20.0 ) ,
const Divider ( height: 1.0 , color: Color ( 0x40ADB0BB ) ) ,
const Divider ( height: 1.0 , color: Color ( 0x40ADB0BB ) ) ,
@ -300,20 +306,38 @@ class _GroupAddPageState extends State<GroupAddPage> {
_requestsLoadMore = false ;
_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 (
width: 600.0 ,
padding: const EdgeInsets . all ( 10.0 ) ,
alignment: Alignment . centerLeft ,
child: Text ( ' 1. ' + lang . groupChatAddr , textAlign: TextAlign . left ,
style: Theme . of ( context ) . textTheme . title ) ,
) ,
Container (
padding: EdgeInsets . only ( bottom: 10.0 ) ,
width: 600.0 ,
child: Row (
mainAxisSize: MainAxisSize . max ,
mainAxisAlignment: MainAxisAlignment . spaceEvenly ,
children: [
_groupAddrWidget ( lang . deviceRemote , 0 , color ) ,
_groupAddrWidget ( lang . deviceLocal , 1 , color ) ,
]
)
) ,
if ( _groupAddr = = 0 )
Container (
Container (
height: 50.0 ,
height: 50.0 ,
width: 600.0 ,
width: 600.0 ,
@ -352,11 +376,10 @@ class _GroupAddPageState extends State<GroupAddPage> {
color: Colors . green ) ,
color: Colors . green ) ,
) ,
) ,
const SizedBox ( width: 8.0 ) ,
const SizedBox ( width: 8.0 ) ,
Container (
InkWell (
width: 100.0 ,
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 ) ,
@ -364,7 +387,20 @@ class _GroupAddPageState extends State<GroupAddPage> {
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 ) ,
InkWell (
onTap: _addrChecked ? _checkGroupAddr : null ,
child: Container (
padding: const EdgeInsets . symmetric ( horizontal: 20.0 ) ,
height: 45.0 ,
decoration: BoxDecoration (
color: Color ( 0xFF6174FF ) ,
borderRadius: BorderRadius . circular ( 15.0 ) ) ,
child: Center (
child: Text ( lang . add ,
style: TextStyle ( fontSize: 16.0 , color: Colors . white ) ) ) ,
) ) ,
] ) ) ,
] ) ) ,
const SizedBox ( height: 8.0 ) ,
const SizedBox ( height: 8.0 ) ,
Text ( checkLang , style: TextStyle ( fontSize: 14.0 ,
Text ( checkLang , style: TextStyle ( fontSize: 14.0 ,
@ -373,7 +409,8 @@ class _GroupAddPageState extends State<GroupAddPage> {
width: 600.0 ,
width: 600.0 ,
padding: const EdgeInsets . all ( 10.0 ) ,
padding: const EdgeInsets . all ( 10.0 ) ,
alignment: Alignment . centerLeft ,
alignment: Alignment . centerLeft ,
child: Text ( ' Group Info ' , textAlign: TextAlign . left , style: TextStyle ( fontSize: 20.0 , fontWeight: FontWeight . bold ) ) ,
child: Text ( ' 2. ' + lang . groupChatInfo , textAlign: TextAlign . left ,
style: Theme . of ( context ) . textTheme . title ) ,
) ,
) ,
Container (
Container (
width: 100.0 ,
width: 100.0 ,
@ -406,17 +443,33 @@ class _GroupAddPageState extends State<GroupAddPage> {
mainAxisSize: MainAxisSize . max ,
mainAxisSize: MainAxisSize . max ,
mainAxisAlignment: MainAxisAlignment . spaceEvenly ,
mainAxisAlignment: MainAxisAlignment . spaceEvenly ,
children: [
children: [
_groupTypeWidget ( ' Encrypted ' , 0 , color ) ,
_groupTypeWidget ( lang . groupTypeEncrypted , 0 , color ) ,
_groupTypeWidget ( ' Common ' , 1 , color ) ,
_groupTypeWidget ( lang . groupTypePrivate , 1 , color ) ,
_groupTypeWidget ( ' Open ' , 2 , 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 )
) ,
child: Text (
_groupType = = 0 ? lang . groupTypeEncryptedInfo
: ( _groupType = = 1 ? lang . groupTypePrivateInfo
: lang . groupTypeOpenInfo ) ,
style: TextStyle ( fontSize: 14.0 , height: 1.5 ,
fontStyle: FontStyle . italic ) ,
textAlign: TextAlign . center ,
) ,
) ,
Container (
Container (
padding: EdgeInsets . symmetric ( vertical: 10.0 ) ,
padding: EdgeInsets . symmetric ( vertical: 10.0 ) ,
child: InputText (
child: InputText (
icon: Icons . account_box ,
icon: Icons . account_box ,
text: ' Group Name ' ,
text: lang . groupChatName ,
controller: _createNameController ,
controller: _createNameController ,
focus: _createNameFocus ) ,
focus: _createNameFocus ) ,
) ,
) ,
@ -424,7 +477,7 @@ class _GroupAddPageState extends State<GroupAddPage> {
padding: EdgeInsets . symmetric ( vertical: 10.0 ) ,
padding: EdgeInsets . symmetric ( vertical: 10.0 ) ,
child: InputText (
child: InputText (
icon: Icons . campaign ,
icon: Icons . campaign ,
text: ' Group Bio ' ,
text: lang . groupChatBio ,
controller: _createBioController ,
controller: _createBioController ,
focus: _createBioFocus ) ,
focus: _createBioFocus ) ,
) ,
) ,
@ -433,7 +486,7 @@ class _GroupAddPageState extends State<GroupAddPage> {
padding: EdgeInsets . symmetric ( vertical: 10.0 ) ,
padding: EdgeInsets . symmetric ( vertical: 10.0 ) ,
child: InputText (
child: InputText (
icon: Icons . enhanced_encryption ,
icon: Icons . enhanced_encryption ,
text: ' Encrypted Key ' ,
text: lang . groupChatKey ,
controller: _createKeyController ,
controller: _createKeyController ,
focus: _createKeyFocus ) ,
focus: _createKeyFocus ) ,
) ,
) ,
@ -451,7 +504,7 @@ class _GroupAddPageState extends State<GroupAddPage> {
} ) ;
} ) ;
} ,
} ,
) ,
) ,
Text ( ' Need Group Manager Agree. ' )
Text ( lang . groupRequireConsent )
]
]
) ,
) ,
) ,
) ,
@ -475,7 +528,6 @@ class _GroupAddPageState extends State<GroupAddPage> {
) ,
) ,
) ,
) ,
) ,
) ,
) ,
] ,
] ,
) ) )
) ) )
) ;
) ;