mirror of
https://github.com/Iconica-Development/flutter_profile.git
synced 2025-05-19 01:03:45 +02:00
Merge pull request #15 from Iconica-Development/feat-onUploadStateChanged-avatar
feat: onUploadStateChanged avatar
This commit is contained in:
commit
8766b9b848
4 changed files with 33 additions and 9 deletions
|
@ -2,6 +2,7 @@
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: BSD-3-Clause
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
|
import 'dart:async';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_profile/flutter_profile.dart';
|
import 'package:flutter_profile/flutter_profile.dart';
|
||||||
|
|
||||||
|
@ -23,7 +24,8 @@ class ExampleProfileService extends ProfileService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> uploadImage(BuildContext context) async {
|
FutureOr<void> uploadImage(BuildContext context,
|
||||||
|
{required Function(bool isUploading) onUploadStateChanged}) {
|
||||||
debugPrint('Updating avatar');
|
debugPrint('Updating avatar');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
// SPDX-License-Identifier: BSD-3-Clause
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_profile/src/models/user.dart';
|
import 'package:flutter_profile/src/models/user.dart';
|
||||||
|
|
||||||
|
@ -21,5 +20,8 @@ abstract class ProfileService {
|
||||||
|
|
||||||
FutureOr<void> editProfile(User user, String key, String? value);
|
FutureOr<void> editProfile(User user, String key, String? value);
|
||||||
|
|
||||||
FutureOr<void> uploadImage(BuildContext context);
|
FutureOr<void> uploadImage(
|
||||||
|
BuildContext context, {
|
||||||
|
required Function(bool isUploading) onUploadStateChanged,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,9 +49,9 @@ class ProfileWrapper extends StatefulWidget {
|
||||||
|
|
||||||
class _ProfileWrapperState extends State<ProfileWrapper> {
|
class _ProfileWrapperState extends State<ProfileWrapper> {
|
||||||
List<Widget> defaultItems = [];
|
List<Widget> defaultItems = [];
|
||||||
|
|
||||||
GlobalKey<FormState> formKey = GlobalKey<FormState>();
|
GlobalKey<FormState> formKey = GlobalKey<FormState>();
|
||||||
Map<String, dynamic> formValues = {};
|
Map<String, dynamic> formValues = {};
|
||||||
|
bool _isUploadingImage = false;
|
||||||
late final Widget child;
|
late final Widget child;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -215,13 +215,28 @@ class _ProfileWrapperState extends State<ProfileWrapper> {
|
||||||
children: [
|
children: [
|
||||||
if (widget.showAvatar) ...[
|
if (widget.showAvatar) ...[
|
||||||
InkWell(
|
InkWell(
|
||||||
onTap: () async {
|
onTap: () => widget.service.uploadImage(
|
||||||
await widget.service.uploadImage(context);
|
context,
|
||||||
},
|
onUploadStateChanged: (isUploading) => setState(
|
||||||
|
() {
|
||||||
|
_isUploadingImage = isUploading;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
child: AvatarWrapper(
|
child: AvatarWrapper(
|
||||||
user: widget.user,
|
user: widget.user,
|
||||||
textStyle: widget.style.avatarTextStyle,
|
textStyle: widget.style.avatarTextStyle,
|
||||||
customAvatar: widget.customAvatar,
|
customAvatar: _isUploadingImage
|
||||||
|
? Container(
|
||||||
|
width: 100,
|
||||||
|
height: 100,
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
color: Colors.black,
|
||||||
|
shape: BoxShape.circle,
|
||||||
|
),
|
||||||
|
child: const CircularProgressIndicator(),
|
||||||
|
)
|
||||||
|
: widget.customAvatar,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: BSD-3-Clause
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_profile/flutter_profile.dart';
|
import 'package:flutter_profile/flutter_profile.dart';
|
||||||
|
|
||||||
|
@ -19,5 +21,8 @@ class TestProfileService extends ProfileService {
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> uploadImage(BuildContext context) async {}
|
FutureOr<void> uploadImage(
|
||||||
|
BuildContext context, {
|
||||||
|
required Function(bool isUploading) onUploadStateChanged,
|
||||||
|
}) {}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue