view.dart 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. import 'package:flutter/material.dart';
  2. import 'package:get/get.dart';
  3. import '../../../../common/models/index.dart';
  4. import '../../../../common/routers/index.dart';
  5. import '../../../../common/utils/index.dart';
  6. import '../../../../common/values/index.dart';
  7. import '../../../../common/widgets/index.dart';
  8. import 'index.dart';
  9. class PersonPage extends GetView<PersonController> {
  10. const PersonPage({Key? key}) : super(key: key);
  11. static void openPersonInfo(O2Person person) {
  12. if (person.id == null || person.id!.isEmpty) {
  13. return;
  14. }
  15. Get.toNamed(O2OARoutes.homeContactPerson, arguments: {"id": person.id!});
  16. }
  17. static void open(String id) {
  18. if (id.isEmpty) {
  19. return;
  20. }
  21. Get.toNamed(O2OARoutes.homeContactPerson, arguments: {"id": id});
  22. }
  23. @override
  24. Widget build(BuildContext context) {
  25. return GetBuilder<PersonController>(
  26. builder: (_) {
  27. return Scaffold(
  28. appBar: AppBar(title: Text("contact_person_info".tr)),
  29. body: SafeArea(
  30. child: ListView(
  31. children: [
  32. const SizedBox(height: 8),
  33. baseAttributeView(context),
  34. const SizedBox(height: 10),
  35. otherAttributeView(context),
  36. Obx(() => Visibility(
  37. visible: controller.state.personAttributeList
  38. .toList()
  39. .isNotEmpty,
  40. child: const SizedBox(height: 10))),
  41. Obx(() => Visibility(
  42. visible: controller.state.personAttributeList
  43. .toList()
  44. .isNotEmpty,
  45. child: personAttributeView(context))),
  46. // 发起聊天按钮
  47. startChatBtnView()
  48. ],
  49. ),
  50. ),
  51. );
  52. },
  53. );
  54. }
  55. /// 基础属性
  56. Widget baseAttributeView(BuildContext context) {
  57. return O2UI.sectionOutBox(
  58. Obx(() => Column(children: [
  59. O2UI.lineWidget(
  60. 'my_profile_avatar'.tr,
  61. controller.state.person.value == null
  62. ? const SizedBox(width: 50, height: 50)
  63. : SizedBox(
  64. width: 50,
  65. height: 50,
  66. child: O2UI.personAvatar(
  67. controller.state.person.value!.distinguishedName!,
  68. 25),
  69. ),
  70. ),
  71. const Divider(height: 1),
  72. O2UI.lineWidget('my_profile_name'.tr,
  73. Text(controller.state.person.value?.name ?? '')),
  74. // const Divider(height: 1),
  75. // O2UI.lineWidget('my_profile_unique'.tr,
  76. // Text(controller.state.person.value?.unique ?? '')),
  77. const Divider(height: 1),
  78. O2UI.lineWidget('my_profile_employee'.tr,
  79. Text(controller.state.person.value?.employee ?? '')),
  80. ])),
  81. context);
  82. }
  83. /// 其他属性
  84. Widget otherAttributeView(BuildContext context) {
  85. return O2UI.sectionOutBox(
  86. Obx(() => Column(children: [
  87. O2UI.lineWidget(
  88. 'contact_person_info_dept_name'.tr,
  89. Text(controller.state.departmentNames,
  90. style: Theme.of(context).textTheme.bodySmall),
  91. ),
  92. const Divider(height: 1),
  93. O2UI.lineWidget(
  94. 'my_profile_superiorName'.tr,
  95. Text(controller.state.superiorName,
  96. style: Theme.of(context).textTheme.bodySmall),
  97. ),
  98. const Divider(height: 1),
  99. O2UI.lineWidget(
  100. 'my_profile_email'.tr,
  101. Text(controller.state.person.value?.mail ?? '',
  102. style: Theme.of(context).textTheme.bodySmall),
  103. ontap: () => controller
  104. .mailTo(controller.state.person.value?.mail ?? '')),
  105. const Divider(height: 1),
  106. O2UI.lineWidget(
  107. 'my_profile_mobile'.tr,
  108. Text(controller.state.person.value?.showMobile ?? '',
  109. style: Theme.of(context).textTheme.bodySmall),
  110. ontap: controller.state.person.value?.showMobile ==
  111. O2.hiddenMobileNumber
  112. ? null
  113. : () => controller
  114. .telTo(controller.state.person.value?.mobile ?? '')),
  115. const Divider(height: 1),
  116. O2UI.lineWidget(
  117. 'my_profile_office_phone'.tr,
  118. Text(controller.state.person.value?.officePhone ?? '',
  119. style: Theme.of(context).textTheme.bodySmall),
  120. ontap: () => controller
  121. .telTo(controller.state.person.value?.officePhone ?? '')),
  122. const Divider(height: 1),
  123. ])),
  124. context);
  125. }
  126. /// 发起聊天按钮
  127. Widget startChatBtnView() {
  128. return Obx(() => Padding(
  129. padding:
  130. const EdgeInsets.only(top: 40, bottom: 10, left: 15, right: 15),
  131. child: O2ApiManager.instance.o2User?.distinguishedName ==
  132. controller.state.person.value?.distinguishedName
  133. ? Container()
  134. : SizedBox(
  135. width: double.infinity,
  136. height: 44,
  137. child: O2ElevatedButton(() {
  138. // 点击
  139. controller.startSingleChat();
  140. },
  141. Text(
  142. 'im_start_single'.tr,
  143. style: const TextStyle(fontSize: 18),
  144. ))),
  145. ));
  146. }
  147. /// 人员属性
  148. Widget personAttributeView(BuildContext context) {
  149. return O2UI.sectionOutBox(Obx(() {
  150. final list = controller.state.personAttributeList.toList();
  151. List<Widget> widgets = [];
  152. for (var element in list) {
  153. widgets.add(O2UI.lineWidget(
  154. element.name ?? '',
  155. Expanded(
  156. flex: 1,
  157. child: Text(
  158. element.attributeList?.join(',') ?? '',
  159. style: Theme.of(context).textTheme.bodySmall,
  160. overflow: TextOverflow.ellipsis,
  161. ),
  162. )));
  163. widgets.add(const Divider(height: 1));
  164. }
  165. return Column(children: widgets);
  166. }), context);
  167. }
  168. }