impl update avatar
This commit is contained in:
parent
1917032d8d
commit
8c8b5d7f51
|
@ -53,5 +53,10 @@
|
|||
<meta-data
|
||||
android:name="flutterEmbedding"
|
||||
android:value="2" />
|
||||
<!-- image_cropper -->
|
||||
<activity
|
||||
android:name="com.yalantis.ucrop.UCropActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
|
||||
</application>
|
||||
</manifest>
|
||||
|
|
|
@ -9,7 +9,7 @@ require (
|
|||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20201108214237-06ea97f0c265
|
||||
github.com/miguelpruivo/flutter_file_picker/go v0.0.0-20210622152105-9f0a811028a0
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/niuhuan/pica-go v0.0.0-20220223122613-0d7d95a9c728
|
||||
github.com/niuhuan/pica-go v0.0.0-20220224154849-76bf750f8c4d
|
||||
github.com/pkg/errors v0.9.1
|
||||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b
|
||||
golang.org/x/mobile v0.0.0-20220224134551-8a0a1e50732f // indirect
|
||||
|
|
|
@ -46,6 +46,8 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
|
|||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/niuhuan/pica-go v0.0.0-20220223122613-0d7d95a9c728 h1:zcO9WFgYbQ3g9U1nbJ6PCelzGB/BaPsCW9jwNry2JXM=
|
||||
github.com/niuhuan/pica-go v0.0.0-20220223122613-0d7d95a9c728/go.mod h1:r76zBgH9AYkv0ptyEVoPUIdt33sT0Ts7xgcg742OZtw=
|
||||
github.com/niuhuan/pica-go v0.0.0-20220224154849-76bf750f8c4d h1:f3V6V1Y+5j/AvhsIGA6aQ/K2Ez1AeYbuCG9uI4fGC6M=
|
||||
github.com/niuhuan/pica-go v0.0.0-20220224154849-76bf750f8c4d/go.mod h1:r76zBgH9AYkv0ptyEVoPUIdt33sT0Ts7xgcg742OZtw=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
|
|
|
@ -1,18 +1,34 @@
|
|||
PODS:
|
||||
- Flutter (1.0.0)
|
||||
- image_cropper (0.0.4):
|
||||
- Flutter
|
||||
- TOCropViewController (~> 2.6.1)
|
||||
- image_picker (0.0.1):
|
||||
- Flutter
|
||||
- "permission_handler (5.1.0+2)":
|
||||
- Flutter
|
||||
- TOCropViewController (2.6.1)
|
||||
- url_launcher_ios (0.0.1):
|
||||
- Flutter
|
||||
|
||||
DEPENDENCIES:
|
||||
- Flutter (from `Flutter`)
|
||||
- image_cropper (from `.symlinks/plugins/image_cropper/ios`)
|
||||
- image_picker (from `.symlinks/plugins/image_picker/ios`)
|
||||
- permission_handler (from `.symlinks/plugins/permission_handler/ios`)
|
||||
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
|
||||
|
||||
SPEC REPOS:
|
||||
trunk:
|
||||
- TOCropViewController
|
||||
|
||||
EXTERNAL SOURCES:
|
||||
Flutter:
|
||||
:path: Flutter
|
||||
image_cropper:
|
||||
:path: ".symlinks/plugins/image_cropper/ios"
|
||||
image_picker:
|
||||
:path: ".symlinks/plugins/image_picker/ios"
|
||||
permission_handler:
|
||||
:path: ".symlinks/plugins/permission_handler/ios"
|
||||
url_launcher_ios:
|
||||
|
@ -20,7 +36,10 @@ EXTERNAL SOURCES:
|
|||
|
||||
SPEC CHECKSUMS:
|
||||
Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a
|
||||
image_cropper: 60c2789d1f1a78c873235d4319ca0c34a69f2d98
|
||||
image_picker: 541dcbb3b9cf32d87eacbd957845d8651d6c62c3
|
||||
permission_handler: ccb20a9fad0ee9b1314a52b70b76b473c5f8dab0
|
||||
TOCropViewController: edfd4f25713d56905ad1e0b9f5be3fbe0f59c863
|
||||
url_launcher_ios: 839c58cdb4279282219f5e248c3321761ff3c4de
|
||||
|
||||
PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c
|
||||
|
|
|
@ -692,4 +692,10 @@ class Method {
|
|||
Future updateSlogan(String input) async {
|
||||
return await _flatInvoke("updateSlogan", input);
|
||||
}
|
||||
|
||||
/// 更新签名
|
||||
Future updateAvatar(String data) async {
|
||||
return await _flatInvoke("updateAvatar", data);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:image_cropper/image_cropper.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:pikapika/basic/Common.dart';
|
||||
import 'package:pikapika/basic/Entities.dart';
|
||||
import 'package:pikapika/basic/Method.dart';
|
||||
|
@ -112,7 +116,14 @@ class _UserProfileCardState extends State<UserProfileCard> {
|
|||
child: Column(
|
||||
children: [
|
||||
Expanded(child: Container()),
|
||||
Avatar(profile.avatar, size: 65),
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
if (Platform.isAndroid || Platform.isIOS) {
|
||||
await _updateAvatarPhone();
|
||||
}
|
||||
},
|
||||
child: Avatar(profile.avatar, size: 65),
|
||||
),
|
||||
Container(height: 5),
|
||||
Text(
|
||||
profile.name,
|
||||
|
@ -134,9 +145,7 @@ class _UserProfileCardState extends State<UserProfileCard> {
|
|||
);
|
||||
if (input != null) {
|
||||
await method.updateSlogan(input);
|
||||
setState(() {
|
||||
_future = _load();
|
||||
});
|
||||
_reload();
|
||||
}
|
||||
},
|
||||
child: Text(
|
||||
|
@ -156,4 +165,46 @@ class _UserProfileCardState extends State<UserProfileCard> {
|
|||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future _updateAvatarPhone() async {
|
||||
final ImagePicker _picker = ImagePicker();
|
||||
final XFile? image = await _picker.pickImage(source: ImageSource.gallery);
|
||||
if (image != null) {
|
||||
final theme = Theme.of(context);
|
||||
final cropper = ImageCropper();
|
||||
File? croppedFile = await cropper.cropImage(
|
||||
sourcePath: image.path,
|
||||
aspectRatioPresets: [
|
||||
CropAspectRatioPreset.square,
|
||||
],
|
||||
aspectRatio: CropAspectRatio(ratioX: 200, ratioY: 200),
|
||||
maxWidth: 200,
|
||||
maxHeight: 200,
|
||||
androidUiSettings: AndroidUiSettings(
|
||||
toolbarTitle: "修改头像",
|
||||
toolbarColor: theme.appBarTheme.backgroundColor,
|
||||
toolbarWidgetColor: Colors.white,
|
||||
initAspectRatio: CropAspectRatioPreset.original,
|
||||
lockAspectRatio: true,
|
||||
),
|
||||
iosUiSettings: IOSUiSettings(
|
||||
resetAspectRatioEnabled: true,
|
||||
aspectRatioLockEnabled: true,
|
||||
title: "修改头像",
|
||||
),
|
||||
);
|
||||
if (croppedFile != null) {
|
||||
var buff = await croppedFile.readAsBytes();
|
||||
var data = base64Encode(buff);
|
||||
await method.updateAvatar(data);
|
||||
_reload();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _reload() {
|
||||
setState(() {
|
||||
_future = _load();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
66
pubspec.lock
66
pubspec.lock
|
@ -7,7 +7,7 @@ packages:
|
|||
name: another_xlider
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.0"
|
||||
version: "1.0.1+2"
|
||||
async:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -57,6 +57,13 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.15.0"
|
||||
cross_file:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: cross_file
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.3.2"
|
||||
cupertino_icons:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -102,6 +109,13 @@ packages:
|
|||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_plugin_android_lifecycle:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: flutter_plugin_android_lifecycle
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.5"
|
||||
flutter_search_bar:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -133,6 +147,48 @@ packages:
|
|||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
http:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: http
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.13.4"
|
||||
http_parser:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: http_parser
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "4.0.0"
|
||||
image_cropper:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: image_cropper
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.5.0"
|
||||
image_picker:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: image_picker
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.8.4+9"
|
||||
image_picker_for_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: image_picker_for_web
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.6"
|
||||
image_picker_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: image_picker_platform_interface
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.4.4"
|
||||
intl:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -319,7 +375,7 @@ packages:
|
|||
name: url_launcher
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "6.0.18"
|
||||
version: "6.0.20"
|
||||
url_launcher_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -340,14 +396,14 @@ packages:
|
|||
name: url_launcher_linux
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.3"
|
||||
version: "3.0.0"
|
||||
url_launcher_macos:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_macos
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.3"
|
||||
version: "3.0.0"
|
||||
url_launcher_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -368,7 +424,7 @@ packages:
|
|||
name: url_launcher_windows
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.2"
|
||||
version: "3.0.0"
|
||||
vector_math:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
@ -43,6 +43,8 @@ dependencies:
|
|||
multi_select_flutter: ^4.0.0
|
||||
flutter_datetime_picker: ^1.5.1
|
||||
modal_bottom_sheet: ^2.0.0
|
||||
image_cropper: ^1.5.0
|
||||
image_picker: ^0.8.4+9
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
|
|
@ -1 +1,7 @@
|
|||
# 编译所有架构的依赖
|
||||
|
||||
cd "$( cd "$( dirname "$0" )" && pwd )/.."
|
||||
|
||||
cd go/mobile
|
||||
|
||||
gomobile bind -target=ios -o lib/Mobile.xcframework ./
|
||||
|
|
|
@ -1 +1,7 @@
|
|||
# 编译所有架构的依赖
|
||||
|
||||
cd "$( cd "$( dirname "$0" )" && pwd )/.."
|
||||
|
||||
cd go/mobile
|
||||
|
||||
gomobile bind -target=ios -o lib/Mobile.xcframework ./
|
||||
|
|
Loading…
Reference in New Issue