123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318 |
- import 'dart:io';
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/foundation.dart';
- import 'package:flutter/material.dart';
- import 'package:image_picker/image_picker.dart';
- import 'package:keyboard_actions/keyboard_actions.dart';
- import 'package:liftmanager/internal/account/model/user_info_entity.dart';
- import 'package:liftmanager/internal/team/page/input_text_page.dart';
- import 'package:liftmanager/net/api_service.dart';
- import 'package:liftmanager/res/resources.dart';
- import 'package:liftmanager/routers/fluro_navigator.dart';
- import 'package:liftmanager/utils/app_navigator.dart';
- import 'package:liftmanager/utils/theme_utils.dart';
- import 'package:liftmanager/utils/toast.dart';
- import 'package:liftmanager/widgets/app_bar.dart';
- import 'package:liftmanager/widgets/click_item.dart';
- import 'package:liftmanager/widgets/load_image.dart';
- import 'package:liftmanager/widgets/my_button.dart';
- import 'package:liftmanager/widgets/selected_image.dart';
- import 'package:liftmanager/widgets/text_field_item.dart';
- class TeamCreatePage extends StatefulWidget {
- @override
- State<StatefulWidget> createState() {
- return TeamCreatePageState();
- }
- }
- class TeamCreatePageState extends State<TeamCreatePage> {
- File _imageFile;
- final FocusNode _nodeText1 = FocusNode();
- final FocusNode _nodeText2 = FocusNode();
- final FocusNode _nodeText3 = FocusNode();
- TextEditingController _teamNameController = TextEditingController();
- TextEditingController _nameController = TextEditingController();
- TextEditingController _phoneController = TextEditingController();
- String _remarks = "";
- void _getImage(int key) async {
- try {
- _imageFile = await ImagePicker.pickImage(
- source: key == 1 ? ImageSource.camera : ImageSource.gallery,
- maxWidth: 800,
- imageQuality: 30);
- setState(() {});
- } catch (e) {
- toasts("没有权限,无法打开相册!");
- }
- }
- @override
- void initState() {
- super.initState();
- getUserInfo();
- }
- UserInfoEntity user;
- ///获取用户信息
- void getUserInfo() {
- ApiService().userInfo(
- onSuccess: (data) {
- print(data);
- user = data;
- _nameController.text = user.userName;
- _phoneController.text = user.mobile;
- setState(() {});
- // setUser(data);
- // _unameController.text = provider.user?.signature;
- },
- onError: (code, msg) {});
- }
- void selectPicker() {
- showDialog(
- context: context,
- builder: (BuildContext context) {
- return SimpleDialog(
- title: Text("选择方式"),
- children: ["拍照", '从手机相册选择'].map((String value) {
- print("$value");
- return SimpleDialogOption(
- child: Text(
- "${value}",
- style: TextStyle(fontSize: 16, fontWeight: FontWeight.w500),
- ),
- onPressed: () {
- _getImage(value == '拍照' ? 1 : 0);
- Navigator.of(context).pop();
- },
- );
- }).toList());
- });
- }
- ///创建团队
- createTeamAction() {
- var team_name = _teamNameController.text.toString().trim();
- var name = _nameController.text.toString().trim();
- var phone = _phoneController.text.toString().trim();
- if (_imageFile == null) {
- toasts("请上传团队logo");
- return;
- }
- if (team_name.isEmpty) {
- toasts("请填写团队名称");
- return;
- }
- if (name.isEmpty) {
- toasts("请填写联系人姓名");
- return;
- }
- if (phone.isEmpty) {
- toasts("请填写联系电话");
- return;
- }
- print(_imageFile.path);
- showLoading(context, "正在创建...");
- NewApiService().upload(_imageFile.path, onSuccess: (data) {
- ApiService(context: context).teamCreate(
- data.pathUrl, team_name, _remarks, name, phone, onSuccess: (data) {
- showAlert(context, "提示", "创建成功", "确定", () {
- dismissLoading(context);
- NavigatorUtils.goBack(context);
- NavigatorUtils.goBackWithParams(context, true);
- });
- }, onError: (code, msg) {
- dismissLoading(context);
- toasts(msg);
- });
- }, onError: (code, msg) {
- toasts(msg);
- });
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- //resizeToAvoidBottomPadding: false,
- appBar: const MyAppBar(
- centerTitle: "创建团队",
- // actions: <Widget>[
- // FlatButton(
- // child: Text("保存", key: const Key('actionName'),style: TextStyle(color: Colors.white),),
- // textColor: Colours.material_bg,
- // color: Colours.material_bg
- // )
- // ],
- ),
- body: SafeArea(
- child: Column(
- children: <Widget>[
- Expanded(
- flex: 1,
- child: defaultTargetPlatform == TargetPlatform.iOS
- ? FormKeyboardActions(
- child: Container(
- color: ThemeUtils.getTabsBg(context),
- child: _buildBody(),
- ))
- : SingleChildScrollView(
- child: Container(
- color: ThemeUtils.getTabsBg(context),
- child: _buildBody(),
- )),
- )
- ],
- ),
- ),
- );
- }
- _buildBody() {
- return Padding(
- padding: const EdgeInsets.symmetric(vertical: 10.0),
- child: Stack(
- children: [
- Column(
- // crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- Gaps.vGap5,
- Row(
- children: [
- Container(
- height: 13,
- width: 2,
- color: Colours.blue_app_main,
- ),
- SizedBox(
- width: 10,
- ),
- Text("团队资料", style: TextStyles.textBold18),
- ],
- ),
- // const Padding(
- // padding: const EdgeInsets.only(left: 16.0),
- // child: const Text("团队资料", style: TextStyles.textBold18),
- // ),
- // Gaps.vGap16,
- // Center(
- // child: SelectedImage(
- // image: _imageFile,
- // onTap: selectPicker
- // ),
- // ),
- // Gaps.vGap10,
- // Center(
- // child: Text(
- // "团队logo",
- // style: Theme.of(context).textTheme.subtitle.copyWith(fontSize: Dimens.font_sp14),
- // ),
- // ),
- // Gaps.vGap16,體育
- ClickItem(
- title: '团队LOGO',
- // subwidget: Container(
- // padding: EdgeInsets.only(right: 10),
- // child: ClipRRect(
- // borderRadius: BorderRadius.circular(15),
- // child: Container(
- // width: 30,
- // height: 30,
- // color: Color(0xffFAF7FA),
- // // padding: EdgeInsets.all(2),
- // child: LoadAssetImage(
- // _imageFile?.path ?? "",
- // // fit: BoxFit.cover,
- // // width: 100,
- // // height: 100,
- // ),
- // ),
- // ),
- // ),
- hasPicRight: "${_imageFile?.path ?? ""}",
- rightPicIsAsset: true,
- onTap: () {
- selectPicker();
- // NavigatorUtils.push(context, BbsRouter.videoDetail);
- },
- ),
- TextFieldItem(
- focusNode: _nodeText1,
- controller: _teamNameController,
- title: "团队名称",
- hintText: "填写团队名称"),
- ClickItem(
- title: "团队简介",
- content: _remarks,
- onTap: () {
- AppNavigator.pushResult(
- context,
- InputTextPage(
- title: "团队简介",
- hintText: "请填写...",
- content: _remarks,
- ), (result) {
- setState(() {
- _remarks = result.toString();
- });
- });
- },
- ),
- Gaps.vGap16,
- Gaps.vGap16,
- Row(
- children: [
- Container(
- height: 13,
- width: 2,
- color: Colours.blue_app_main,
- ),
- SizedBox(
- width: 10,
- ),
- Text("联系人信息", style: TextStyles.textBold18),
- ],
- ),
- // const Padding(
- // padding: const EdgeInsets.only(left: 16.0),
- // child: const Text("联系人信息", style: TextStyles.textBold18),
- // ),
- TextFieldItem(
- focusNode: _nodeText2,
- enabled: false,
- title: "联系人",
- controller: _nameController,
- hintText: ""),
- TextFieldItem(
- focusNode: _nodeText3,
- title: "联系电话",
- enabled: false,
- controller: _phoneController,
- hintText: ""),
- // Expanded(child: Container()),
- SizedBox(
- height: 100,
- ),
- ],
- ),
- Positioned(
- bottom: 5,
- left: 5,
- right: 5,
- child: MyButton(
- backColor: Colours.blue_app_main,
- onPressed: () {
- createTeamAction();
- },
- text: "提交",
- ),
- )
- ],
- ));
- }
- }
|