Hibok
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 
 

138 строки
4.0 KiB

  1. import 'package:chat/data/constants.dart';
  2. import 'package:chat/generated/i18n.dart';
  3. import 'package:chat/models/group_info_model.dart';
  4. import 'package:chat/utils/CustomUI.dart';
  5. import 'package:chat/utils/FullWithButton.dart';
  6. import 'package:chat/utils/msgHandler.dart';
  7. import 'package:flutter/material.dart';
  8. import 'create_group_view.dart';
  9. class GroupManagePage extends StatefulWidget {
  10. final GroupInfoModel groupInfoModel;
  11. GroupManagePage({Key key, @required this.groupInfoModel}) : super(key: key);
  12. @override
  13. _GroupManagePageState createState() => new _GroupManagePageState();
  14. }
  15. class _GroupManagePageState extends State<GroupManagePage> {
  16. bool invite = false; //消息提示
  17. @override
  18. void initState() {
  19. super.initState();
  20. invite = widget.groupInfoModel.askSwitch == 1;
  21. }
  22. Widget _buildSettingWithSwitch(
  23. bool switchValue, String title, Function onchang) {
  24. Widget left = new Text(
  25. title,
  26. textScaleFactor: 1.0,
  27. style: TextStyle(fontSize: 14, fontWeight: FontWeight.normal),
  28. );
  29. Widget right = new Expanded(
  30. child: new Align(
  31. alignment: Alignment.centerRight,
  32. child: new Switch(
  33. value: switchValue,
  34. activeTrackColor: Constants.ConfrimButtonColor.withOpacity(0.3),
  35. onChanged: onchang,
  36. )));
  37. return new Container(
  38. decoration: BoxDecoration(
  39. color: Colors.white,
  40. ),
  41. padding: EdgeInsets.only(left: 20),
  42. height: 53,
  43. child: new Row(
  44. children: <Widget>[left, right],
  45. ),
  46. );
  47. }
  48. @override
  49. Widget build(BuildContext context) {
  50. Widget appBar = new AppBar(
  51. backgroundColor: AppColors.NewAppbarBgColor,
  52. title: new Text(
  53. I18n.of(context).group_setting,
  54. style: TextStyle(color: AppColors.NewAppbarTextColor),
  55. textScaleFactor: 1.0,
  56. ),
  57. leading: CustomUI.buildCustomLeading(context),
  58. centerTitle: true,
  59. );
  60. return Scaffold(
  61. appBar: appBar,
  62. body: SafeArea(
  63. child: _buildBody(),
  64. ));
  65. }
  66. Widget _buildBody() {
  67. return Container(
  68. child: Column(
  69. crossAxisAlignment: CrossAxisAlignment.start,
  70. children: <Widget>[
  71. SizedBox(
  72. height: 7,
  73. ),
  74. ///群聊邀请确认
  75. _buildSettingWithSwitch(invite, I18n.of(context).group_invite,
  76. (bool val) {
  77. setState(() {
  78. invite = val;
  79. MsgHandler.setGroupSwitch(
  80. widget.groupInfoModel.sessionId, invite);
  81. });
  82. }),
  83. _buildTips(),
  84. Container(
  85. color: Colors.white,
  86. padding: EdgeInsets.only(left: 10),
  87. height: 53,
  88. child: FullWidthButton(
  89. title: I18n.of(context).change_group_owner,
  90. showDivider: false,
  91. showRightIcon: true,
  92. onPressed: () async {
  93. String str = await Navigator.of(context).push(
  94. new MaterialPageRoute(
  95. builder: (context) {
  96. return CreateGroupPage(
  97. GroupOperatingPageType.SelectGroupOwner,
  98. widget.groupInfoModel.members,
  99. widget.groupInfoModel.sessionId);
  100. },
  101. ),
  102. );
  103. if (str == 'close') {
  104. Navigator.pop(context);
  105. }
  106. },
  107. ))
  108. ],
  109. ),
  110. );
  111. }
  112. Widget _buildTips() {
  113. return Container(
  114. margin: EdgeInsets.only(top: 10, bottom: 10, left: 15, right: 15),
  115. child: Text(
  116. I18n.of(context).group_setting_tips,
  117. textScaleFactor: 1.0,
  118. style: TextStyle(fontSize: 10.5, color: Constants.GreyTextColor),
  119. ),
  120. );
  121. }
  122. @override
  123. void dispose() {
  124. super.dispose();
  125. }
  126. }