refactor: remove unused color_utils import and replace with username_color_generator in call and contact pages
This commit is contained in:
parent
6fc2991d1e
commit
960ddd8e8f
@ -1,37 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
/// Generates a color based on a string input (typically a name)
|
|
||||||
Color generateColorFromName(String name) {
|
|
||||||
if (name.isEmpty) return Colors.grey;
|
|
||||||
|
|
||||||
// Use the hashCode of the name to generate a consistent color
|
|
||||||
int hash = name.hashCode;
|
|
||||||
|
|
||||||
// Use the hash to generate RGB values
|
|
||||||
final r = (hash & 0xFF0000) >> 16;
|
|
||||||
final g = (hash & 0x00FF00) >> 8;
|
|
||||||
final b = hash & 0x0000FF;
|
|
||||||
|
|
||||||
// Create a color with these RGB values
|
|
||||||
return Color.fromARGB(255, r, g, b);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Darkens a color by a percentage (0.0 to 1.0)
|
|
||||||
Color darken(Color color, [double amount = 0.3]) {
|
|
||||||
assert(amount >= 0 && amount <= 1);
|
|
||||||
|
|
||||||
final hsl = HSLColor.fromColor(color);
|
|
||||||
final darkened = hsl.withLightness((hsl.lightness - amount).clamp(0.0, 1.0));
|
|
||||||
|
|
||||||
return darkened.toColor();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Lightens a color by a percentage (0.0 to 1.0)
|
|
||||||
Color lighten(Color color, [double amount = 0.3]) {
|
|
||||||
assert(amount >= 0 && amount <= 1);
|
|
||||||
|
|
||||||
final hsl = HSLColor.fromColor(color);
|
|
||||||
final lightened = hsl.withLightness((hsl.lightness + amount).clamp(0.0, 1.0));
|
|
||||||
|
|
||||||
return lightened.toColor();
|
|
||||||
}
|
|
@ -3,7 +3,7 @@ import 'package:flutter/services.dart';
|
|||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
import '../../../domain/services/call_service.dart';
|
import '../../../domain/services/call_service.dart';
|
||||||
import '../../../domain/services/obfuscate_service.dart';
|
import '../../../domain/services/obfuscate_service.dart';
|
||||||
import '../../../core/utils/color_utils.dart';
|
import 'package:dialer/presentation/common/widgets/username_color_generator.dart';
|
||||||
// import '../../../presentation/common/widgets/obfuscated_avatar.dart';
|
// import '../../../presentation/common/widgets/obfuscated_avatar.dart';
|
||||||
|
|
||||||
class CallPage extends StatefulWidget {
|
class CallPage extends StatefulWidget {
|
||||||
|
@ -3,7 +3,7 @@ import 'package:flutter/services.dart';
|
|||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
import '../../../domain/services/call_service.dart';
|
import '../../../domain/services/call_service.dart';
|
||||||
import '../../../domain/services/obfuscate_service.dart';
|
import '../../../domain/services/obfuscate_service.dart';
|
||||||
import '../../../core/utils/color_utils.dart';
|
import 'package:dialer/presentation/common/widgets/username_color_generator.dart';
|
||||||
import 'call_page.dart';
|
import 'call_page.dart';
|
||||||
|
|
||||||
class IncomingCallPage extends StatefulWidget {
|
class IncomingCallPage extends StatefulWidget {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_contacts/flutter_contacts.dart';
|
import 'package:flutter_contacts/flutter_contacts.dart';
|
||||||
import '../../../../domain/services/obfuscate_service.dart';
|
import '../../../../domain/services/obfuscate_service.dart';
|
||||||
import '../../../../core/utils/color_utils.dart';
|
import 'package:dialer/presentation/common/widgets/username_color_generator.dart';
|
||||||
import '../contact_state.dart';
|
import '../contact_state.dart';
|
||||||
import 'add_contact_button.dart';
|
import 'add_contact_button.dart';
|
||||||
import 'contact_modal.dart';
|
import 'contact_modal.dart';
|
||||||
|
Loading…
Reference in New Issue
Block a user