Add Edit Badge
continuous-integration/drone/pr Build is pending
Details
continuous-integration/drone/pr Build is pending
Details
This commit is contained in:
parent
d902ba5cce
commit
403454d6b8
|
@ -91,10 +91,10 @@ class _AddEditProfileViewState extends State<AddEditProfileView> {
|
||||||
visible: Provider.of<ProfileInfoState>(context).onion.isNotEmpty,
|
visible: Provider.of<ProfileInfoState>(context).onion.isNotEmpty,
|
||||||
child: Row(mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[
|
child: Row(mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[
|
||||||
MouseRegion(
|
MouseRegion(
|
||||||
cursor: Provider.of<Settings>(context).isExperimentEnabled(ImagePreviewsExperiment) ? SystemMouseCursors.click : SystemMouseCursors.basic,
|
cursor: Provider.of<Settings>(context, listen: false).isExperimentEnabled(ImagePreviewsExperiment) ? SystemMouseCursors.click : SystemMouseCursors.basic,
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
// don't allow setting of profile images if the image previews experiment is disabled.
|
// don't allow setting of profile images if the image previews experiment is disabled.
|
||||||
onTap: Provider.of<AppState>(context).disableFilePicker || !Provider.of<Settings>(context).isExperimentEnabled(ImagePreviewsExperiment)
|
onTap: Provider.of<AppState>(context).disableFilePicker || !Provider.of<Settings>(context, listen: false).isExperimentEnabled(ImagePreviewsExperiment)
|
||||||
? null
|
? null
|
||||||
: () {
|
: () {
|
||||||
filesharing.showFilePicker(context, MaxImageFileSharingSize, (File file) {
|
filesharing.showFilePicker(context, MaxImageFileSharingSize, (File file) {
|
||||||
|
@ -112,17 +112,17 @@ class _AddEditProfileViewState extends State<AddEditProfileView> {
|
||||||
}, () {});
|
}, () {});
|
||||||
},
|
},
|
||||||
child: ProfileImage(
|
child: ProfileImage(
|
||||||
imagePath: Provider.of<Settings>(context).isExperimentEnabled(ImagePreviewsExperiment)
|
imagePath: Provider.of<Settings>(context).isExperimentEnabled(ImagePreviewsExperiment)
|
||||||
? Provider.of<ProfileInfoState>(context).imagePath
|
? Provider.of<ProfileInfoState>(context).imagePath
|
||||||
: Provider.of<ProfileInfoState>(context).defaultImagePath,
|
: Provider.of<ProfileInfoState>(context).defaultImagePath,
|
||||||
diameter: 120,
|
diameter: 120,
|
||||||
tooltip:
|
tooltip:
|
||||||
Provider.of<Settings>(context).isExperimentEnabled(ImagePreviewsExperiment) ? AppLocalizations.of(context)!.tooltipSelectACustomProfileImage : "",
|
Provider.of<Settings>(context).isExperimentEnabled(ImagePreviewsExperiment) ? AppLocalizations.of(context)!.tooltipSelectACustomProfileImage : "",
|
||||||
maskOut: false,
|
maskOut: false,
|
||||||
border: theme.theme.portraitOnlineBorderColor,
|
border: theme.theme.portraitOnlineBorderColor,
|
||||||
badgeTextColor: Colors.red,
|
badgeTextColor: theme.theme.portraitContactBadgeTextColor,
|
||||||
badgeColor: Colors.red,
|
badgeColor: theme.theme.portraitContactBadgeColor,
|
||||||
)))
|
badgeEdit: Provider.of<Settings>(context).isExperimentEnabled(ImagePreviewsExperiment))))
|
||||||
])),
|
])),
|
||||||
Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||||
CwtchLabel(label: AppLocalizations.of(context)!.displayNameLabel),
|
CwtchLabel(label: AppLocalizations.of(context)!.displayNameLabel),
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:cwtch/themes/opaque.dart';
|
import 'package:cwtch/themes/opaque.dart';
|
||||||
|
@ -8,7 +9,15 @@ import '../settings.dart';
|
||||||
|
|
||||||
class ProfileImage extends StatefulWidget {
|
class ProfileImage extends StatefulWidget {
|
||||||
ProfileImage(
|
ProfileImage(
|
||||||
{required this.imagePath, required this.diameter, required this.border, this.badgeCount = 0, required this.badgeColor, required this.badgeTextColor, this.maskOut = false, this.tooltip = ""});
|
{required this.imagePath,
|
||||||
|
required this.diameter,
|
||||||
|
required this.border,
|
||||||
|
this.badgeCount = 0,
|
||||||
|
required this.badgeColor,
|
||||||
|
required this.badgeTextColor,
|
||||||
|
this.maskOut = false,
|
||||||
|
this.tooltip = "",
|
||||||
|
this.badgeEdit = false});
|
||||||
final double diameter;
|
final double diameter;
|
||||||
final String imagePath;
|
final String imagePath;
|
||||||
final Color border;
|
final Color border;
|
||||||
|
@ -16,6 +25,7 @@ class ProfileImage extends StatefulWidget {
|
||||||
final Color badgeColor;
|
final Color badgeColor;
|
||||||
final Color badgeTextColor;
|
final Color badgeTextColor;
|
||||||
final bool maskOut;
|
final bool maskOut;
|
||||||
|
final bool badgeEdit;
|
||||||
final String tooltip;
|
final String tooltip;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -70,14 +80,19 @@ class _ProfileImageState extends State<ProfileImage> {
|
||||||
padding: const EdgeInsets.all(2.0), //border size
|
padding: const EdgeInsets.all(2.0), //border size
|
||||||
child: ClipOval(clipBehavior: Clip.antiAlias, child: widget.tooltip == "" ? image : Tooltip(message: widget.tooltip, child: image))))),
|
child: ClipOval(clipBehavior: Clip.antiAlias, child: widget.tooltip == "" ? image : Tooltip(message: widget.tooltip, child: image))))),
|
||||||
Visibility(
|
Visibility(
|
||||||
visible: widget.badgeCount > 0,
|
visible: widget.badgeEdit || widget.badgeCount > 0,
|
||||||
child: Positioned(
|
child: Positioned(
|
||||||
bottom: 0.0,
|
bottom: 0.0,
|
||||||
right: 0.0,
|
right: 0.0,
|
||||||
child: CircleAvatar(
|
child: CircleAvatar(
|
||||||
radius: 10.0,
|
radius: max(10.0, widget.diameter / 6.0),
|
||||||
backgroundColor: widget.badgeColor,
|
backgroundColor: widget.badgeColor,
|
||||||
child: Text(widget.badgeCount > 99 ? "99+" : widget.badgeCount.toString(), style: TextStyle(color: widget.badgeTextColor, fontSize: 8.0)),
|
child: widget.badgeEdit
|
||||||
|
? Icon(
|
||||||
|
Icons.edit,
|
||||||
|
color: widget.badgeTextColor,
|
||||||
|
)
|
||||||
|
: Text(widget.badgeCount > 99 ? "99+" : widget.badgeCount.toString(), style: TextStyle(color: widget.badgeTextColor, fontSize: 8.0)),
|
||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
]));
|
]));
|
||||||
|
|
Loading…
Reference in New Issue