mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-07-23 14:40:58 -04:00
contact invitation algorithm
This commit is contained in:
parent
c35056f687
commit
f52094c105
43 changed files with 1319 additions and 451 deletions
|
@ -2,59 +2,13 @@
|
|||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_chat_ui/flutter_chat_ui.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../entities/preferences.dart';
|
||||
import 'radix_generator.dart';
|
||||
|
||||
@immutable
|
||||
class ExtendedColorScheme extends ColorScheme {
|
||||
const ExtendedColorScheme({
|
||||
required this.scaleScheme,
|
||||
required super.brightness,
|
||||
required super.primary,
|
||||
required super.onPrimary,
|
||||
super.primaryContainer,
|
||||
super.onPrimaryContainer,
|
||||
required super.secondary,
|
||||
required super.onSecondary,
|
||||
super.secondaryContainer,
|
||||
super.onSecondaryContainer,
|
||||
super.tertiary,
|
||||
super.onTertiary,
|
||||
super.tertiaryContainer,
|
||||
super.onTertiaryContainer,
|
||||
required super.error,
|
||||
required super.onError,
|
||||
super.errorContainer,
|
||||
super.onErrorContainer,
|
||||
required super.background,
|
||||
required super.onBackground,
|
||||
required super.surface,
|
||||
required super.onSurface,
|
||||
super.surfaceVariant,
|
||||
super.onSurfaceVariant,
|
||||
super.outline,
|
||||
super.outlineVariant,
|
||||
super.shadow,
|
||||
super.scrim,
|
||||
super.inverseSurface,
|
||||
super.onInverseSurface,
|
||||
super.inversePrimary,
|
||||
super.surfaceTint,
|
||||
});
|
||||
|
||||
final ScaleScheme scaleScheme;
|
||||
|
||||
@override
|
||||
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
||||
super.debugFillProperties(properties);
|
||||
properties.add(DiagnosticsProperty<ScaleScheme>('scales', scaleScheme));
|
||||
}
|
||||
}
|
||||
|
||||
class ScaleColor {
|
||||
ScaleColor({
|
||||
required this.appBackground,
|
||||
|
@ -83,9 +37,69 @@ class ScaleColor {
|
|||
Color hoverBackground;
|
||||
Color subtleText;
|
||||
Color text;
|
||||
|
||||
ScaleColor copyWith(
|
||||
{Color? appBackground,
|
||||
Color? subtleBackground,
|
||||
Color? elementBackground,
|
||||
Color? hoverElementBackground,
|
||||
Color? activedElementBackground,
|
||||
Color? subtleBorder,
|
||||
Color? border,
|
||||
Color? hoverBorder,
|
||||
Color? background,
|
||||
Color? hoverBackground,
|
||||
Color? subtleText,
|
||||
Color? text}) =>
|
||||
ScaleColor(
|
||||
appBackground: appBackground ?? this.appBackground,
|
||||
subtleBackground: subtleBackground ?? this.subtleBackground,
|
||||
elementBackground: elementBackground ?? this.elementBackground,
|
||||
hoverElementBackground:
|
||||
hoverElementBackground ?? this.hoverElementBackground,
|
||||
activedElementBackground:
|
||||
activedElementBackground ?? this.activedElementBackground,
|
||||
subtleBorder: subtleBorder ?? this.subtleBorder,
|
||||
border: border ?? this.border,
|
||||
hoverBorder: hoverBorder ?? this.hoverBorder,
|
||||
background: background ?? this.background,
|
||||
hoverBackground: hoverBackground ?? this.hoverBackground,
|
||||
subtleText: subtleText ?? this.subtleText,
|
||||
text: text ?? this.text,
|
||||
);
|
||||
|
||||
// ignore: prefer_constructors_over_static_methods
|
||||
static ScaleColor lerp(ScaleColor a, ScaleColor b, double t) => ScaleColor(
|
||||
appBackground: Color.lerp(a.appBackground, b.appBackground, t) ??
|
||||
const Color(0x00000000),
|
||||
subtleBackground:
|
||||
Color.lerp(a.subtleBackground, b.subtleBackground, t) ??
|
||||
const Color(0x00000000),
|
||||
elementBackground:
|
||||
Color.lerp(a.elementBackground, b.elementBackground, t) ??
|
||||
const Color(0x00000000),
|
||||
hoverElementBackground:
|
||||
Color.lerp(a.hoverElementBackground, b.hoverElementBackground, t) ??
|
||||
const Color(0x00000000),
|
||||
activedElementBackground: Color.lerp(
|
||||
a.activedElementBackground, b.activedElementBackground, t) ??
|
||||
const Color(0x00000000),
|
||||
subtleBorder: Color.lerp(a.subtleBorder, b.subtleBorder, t) ??
|
||||
const Color(0x00000000),
|
||||
border: Color.lerp(a.border, b.border, t) ?? const Color(0x00000000),
|
||||
hoverBorder: Color.lerp(a.hoverBorder, b.hoverBorder, t) ??
|
||||
const Color(0x00000000),
|
||||
background: Color.lerp(a.background, b.background, t) ??
|
||||
const Color(0x00000000),
|
||||
hoverBackground: Color.lerp(a.hoverBackground, b.hoverBackground, t) ??
|
||||
const Color(0x00000000),
|
||||
subtleText: Color.lerp(a.subtleText, b.subtleText, t) ??
|
||||
const Color(0x00000000),
|
||||
text: Color.lerp(a.text, b.text, t) ?? const Color(0x00000000),
|
||||
);
|
||||
}
|
||||
|
||||
class ScaleScheme {
|
||||
class ScaleScheme extends ThemeExtension<ScaleScheme> {
|
||||
ScaleScheme(
|
||||
{required this.primaryScale,
|
||||
required this.primaryAlphaScale,
|
||||
|
@ -94,15 +108,66 @@ class ScaleScheme {
|
|||
required this.grayScale,
|
||||
required this.errorScale});
|
||||
|
||||
ScaleColor primaryScale;
|
||||
ScaleColor primaryAlphaScale;
|
||||
ScaleColor secondaryScale;
|
||||
ScaleColor tertiaryScale;
|
||||
ScaleColor grayScale;
|
||||
ScaleColor errorScale;
|
||||
final ScaleColor primaryScale;
|
||||
final ScaleColor primaryAlphaScale;
|
||||
final ScaleColor secondaryScale;
|
||||
final ScaleColor tertiaryScale;
|
||||
final ScaleColor grayScale;
|
||||
final ScaleColor errorScale;
|
||||
|
||||
static ScaleScheme of(BuildContext context) =>
|
||||
(Theme.of(context).colorScheme as ExtendedColorScheme).scaleScheme;
|
||||
@override
|
||||
ScaleScheme copyWith(
|
||||
{ScaleColor? primaryScale,
|
||||
ScaleColor? primaryAlphaScale,
|
||||
ScaleColor? secondaryScale,
|
||||
ScaleColor? tertiaryScale,
|
||||
ScaleColor? grayScale,
|
||||
ScaleColor? errorScale}) =>
|
||||
ScaleScheme(
|
||||
primaryScale: primaryScale ?? this.primaryScale,
|
||||
primaryAlphaScale: primaryAlphaScale ?? this.primaryAlphaScale,
|
||||
secondaryScale: secondaryScale ?? this.secondaryScale,
|
||||
tertiaryScale: tertiaryScale ?? this.tertiaryScale,
|
||||
grayScale: grayScale ?? this.grayScale,
|
||||
errorScale: errorScale ?? this.errorScale,
|
||||
);
|
||||
|
||||
@override
|
||||
ScaleScheme lerp(ScaleScheme? other, double t) {
|
||||
if (other is! ScaleScheme) {
|
||||
return this;
|
||||
}
|
||||
return ScaleScheme(
|
||||
primaryScale: ScaleColor.lerp(primaryScale, other.primaryScale, t),
|
||||
primaryAlphaScale:
|
||||
ScaleColor.lerp(primaryAlphaScale, other.primaryAlphaScale, t),
|
||||
secondaryScale: ScaleColor.lerp(secondaryScale, other.secondaryScale, t),
|
||||
tertiaryScale: ScaleColor.lerp(tertiaryScale, other.tertiaryScale, t),
|
||||
grayScale: ScaleColor.lerp(grayScale, other.grayScale, t),
|
||||
errorScale: ScaleColor.lerp(errorScale, other.errorScale, t),
|
||||
);
|
||||
}
|
||||
|
||||
ChatTheme toChatTheme() => DefaultChatTheme(
|
||||
primaryColor: primaryScale.background,
|
||||
secondaryColor: secondaryScale.background,
|
||||
backgroundColor: grayScale.subtleBackground,
|
||||
inputBackgroundColor: primaryScale.appBackground,
|
||||
inputBorderRadius: BorderRadius.zero,
|
||||
inputTextDecoration: InputDecoration(
|
||||
border: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: primaryScale.subtleBorder),
|
||||
borderRadius: const BorderRadius.all(Radius.circular(16))),
|
||||
),
|
||||
inputContainerDecoration: BoxDecoration(color: grayScale.appBackground),
|
||||
inputPadding: EdgeInsets.all(5),
|
||||
inputTextStyle: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
height: 1,
|
||||
),
|
||||
attachmentButtonIcon: Icon(Icons.attach_file),
|
||||
);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue