forked from cwtch.im/cwtch-ui
Add Edit Badge
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,
|
||||
child: Row(mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[
|
||||
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(
|
||||
// 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
|
||||
: () {
|
||||
filesharing.showFilePicker(context, MaxImageFileSharingSize, (File file) {
|
||||
|
@ -112,17 +112,17 @@ class _AddEditProfileViewState extends State<AddEditProfileView> {
|
|||
}, () {});
|
||||
},
|
||||
child: ProfileImage(
|
||||
imagePath: Provider.of<Settings>(context).isExperimentEnabled(ImagePreviewsExperiment)
|
||||
? Provider.of<ProfileInfoState>(context).imagePath
|
||||
: Provider.of<ProfileInfoState>(context).defaultImagePath,
|
||||
diameter: 120,
|
||||
tooltip:
|
||||
Provider.of<Settings>(context).isExperimentEnabled(ImagePreviewsExperiment) ? AppLocalizations.of(context)!.tooltipSelectACustomProfileImage : "",
|
||||
maskOut: false,
|
||||
border: theme.theme.portraitOnlineBorderColor,
|
||||
badgeTextColor: Colors.red,
|
||||
badgeColor: Colors.red,
|
||||
)))
|
||||
imagePath: Provider.of<Settings>(context).isExperimentEnabled(ImagePreviewsExperiment)
|
||||
? Provider.of<ProfileInfoState>(context).imagePath
|
||||
: Provider.of<ProfileInfoState>(context).defaultImagePath,
|
||||
diameter: 120,
|
||||
tooltip:
|
||||
Provider.of<Settings>(context).isExperimentEnabled(ImagePreviewsExperiment) ? AppLocalizations.of(context)!.tooltipSelectACustomProfileImage : "",
|
||||
maskOut: false,
|
||||
border: theme.theme.portraitOnlineBorderColor,
|
||||
badgeTextColor: theme.theme.portraitContactBadgeTextColor,
|
||||
badgeColor: theme.theme.portraitContactBadgeColor,
|
||||
badgeEdit: Provider.of<Settings>(context).isExperimentEnabled(ImagePreviewsExperiment))))
|
||||
])),
|
||||
Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||
CwtchLabel(label: AppLocalizations.of(context)!.displayNameLabel),
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import 'dart:io';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cwtch/themes/opaque.dart';
|
||||
|
@ -8,7 +9,15 @@ import '../settings.dart';
|
|||
|
||||
class ProfileImage extends StatefulWidget {
|
||||
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 String imagePath;
|
||||
final Color border;
|
||||
|
@ -16,6 +25,7 @@ class ProfileImage extends StatefulWidget {
|
|||
final Color badgeColor;
|
||||
final Color badgeTextColor;
|
||||
final bool maskOut;
|
||||
final bool badgeEdit;
|
||||
final String tooltip;
|
||||
|
||||
@override
|
||||
|
@ -70,14 +80,19 @@ class _ProfileImageState extends State<ProfileImage> {
|
|||
padding: const EdgeInsets.all(2.0), //border size
|
||||
child: ClipOval(clipBehavior: Clip.antiAlias, child: widget.tooltip == "" ? image : Tooltip(message: widget.tooltip, child: image))))),
|
||||
Visibility(
|
||||
visible: widget.badgeCount > 0,
|
||||
visible: widget.badgeEdit || widget.badgeCount > 0,
|
||||
child: Positioned(
|
||||
bottom: 0.0,
|
||||
right: 0.0,
|
||||
child: CircleAvatar(
|
||||
radius: 10.0,
|
||||
radius: max(10.0, widget.diameter / 6.0),
|
||||
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