ui cleanup

This commit is contained in:
Christien Rioux 2025-03-17 00:51:16 -04:00
parent d460a0388c
commit 77c68aa45f
57 changed files with 1158 additions and 914 deletions

View file

@ -1,12 +1,16 @@
import 'package:flutter/widgets.dart';
import 'package:equatable/equatable.dart';
import 'package:meta/meta.dart';
import 'package:protobuf/protobuf.dart';
import 'package:veilid_support/veilid_support.dart';
import '../../proto/proto.dart' as proto;
/// Profile and Account configurable fields
/// Some are publicly visible via the proto.Profile
/// Some are privately held as proto.Account configurations
class AccountSpec {
AccountSpec(
@immutable
class AccountSpec extends Equatable {
const AccountSpec(
{required this.name,
required this.pronouns,
required this.about,
@ -19,37 +23,99 @@ class AccountSpec {
required this.autoAway,
required this.autoAwayTimeout});
const AccountSpec.empty()
: name = '',
pronouns = '',
about = '',
availability = proto.Availability.AVAILABILITY_FREE,
invisible = false,
freeMessage = '',
awayMessage = '',
busyMessage = '',
avatar = null,
autoAway = false,
autoAwayTimeout = 15;
AccountSpec.fromProto(proto.Account p)
: name = p.profile.name,
pronouns = p.profile.pronouns,
about = p.profile.about,
availability = p.profile.availability,
invisible = p.invisible,
freeMessage = p.freeMessage,
awayMessage = p.awayMessage,
busyMessage = p.busyMessage,
avatar = p.profile.hasAvatar() ? p.profile.avatar : null,
autoAway = p.autodetectAway,
autoAwayTimeout = p.autoAwayTimeoutMin;
String get status {
late final String status;
switch (availability) {
case proto.Availability.AVAILABILITY_AWAY:
status = awayMessage;
break;
case proto.Availability.AVAILABILITY_BUSY:
status = busyMessage;
break;
case proto.Availability.AVAILABILITY_FREE:
status = freeMessage;
break;
case proto.Availability.AVAILABILITY_UNSPECIFIED:
case proto.Availability.AVAILABILITY_OFFLINE:
status = '';
break;
}
return status;
}
Future<proto.Account> updateProto(proto.Account old) async {
final newProto = old.deepCopy()
..profile.name = name
..profile.pronouns = pronouns
..profile.about = about
..profile.availability = availability
..profile.status = status
..profile.timestamp = Veilid.instance.now().toInt64()
..invisible = invisible
..autodetectAway = autoAway
..autoAwayTimeoutMin = autoAwayTimeout
..freeMessage = freeMessage
..awayMessage = awayMessage
..busyMessage = busyMessage;
final newAvatar = avatar;
if (newAvatar != null) {
newProto.profile.avatar = newAvatar;
} else {
newProto.profile.clearAvatar();
}
return newProto;
}
////////////////////////////////////////////////////////////////////////////
String name;
String pronouns;
String about;
proto.Availability availability;
bool invisible;
String freeMessage;
String awayMessage;
String busyMessage;
ImageProvider? avatar;
bool autoAway;
int autoAwayTimeout;
final String name;
final String pronouns;
final String about;
final proto.Availability availability;
final bool invisible;
final String freeMessage;
final String awayMessage;
final String busyMessage;
final proto.DataReference? avatar;
final bool autoAway;
final int autoAwayTimeout;
@override
List<Object?> get props => [
name,
pronouns,
about,
availability,
invisible,
freeMessage,
awayMessage,
busyMessage,
avatar,
autoAway,
autoAwayTimeout
];
}