diff --git a/packages/neon/neon/lib/src/utils/branding.dart b/packages/neon/neon/lib/src/utils/branding.dart index 9b758b17..c0e5607b 100644 --- a/packages/neon/neon/lib/src/utils/branding.dart +++ b/packages/neon/neon/lib/src/utils/branding.dart @@ -1,7 +1,8 @@ part of '../../neon.dart'; +@immutable class Branding { - Branding({ + const Branding({ required this.name, required this.logo, this.legalese, diff --git a/packages/neon/neon/lib/src/utils/global_popups.dart b/packages/neon/neon/lib/src/utils/global_popups.dart index 43ac125c..aa79a40f 100644 --- a/packages/neon/neon/lib/src/utils/global_popups.dart +++ b/packages/neon/neon/lib/src/utils/global_popups.dart @@ -1,10 +1,16 @@ part of '../../neon.dart'; class GlobalPopups { - factory GlobalPopups() => _instance ??= GlobalPopups._(); + factory GlobalPopups() => instance ??= GlobalPopups._(); + + @visibleForTesting + factory GlobalPopups.mocked(final GlobalPopups mock) => instance ??= mock; + GlobalPopups._(); - static GlobalPopups? _instance; + @visibleForTesting + static GlobalPopups? instance; + bool _registered = false; void register(final BuildContext context) { diff --git a/packages/neon/neon/lib/src/utils/hex_color.dart b/packages/neon/neon/lib/src/utils/hex_color.dart index 2e1e569a..670e28ab 100644 --- a/packages/neon/neon/lib/src/utils/hex_color.dart +++ b/packages/neon/neon/lib/src/utils/hex_color.dart @@ -1,11 +1,11 @@ part of '../../neon.dart'; class HexColor extends Color { - HexColor(final String hexColor) - : super( - int.parse( - hexColor.toUpperCase().replaceAll('#', '').padLeft(8, 'F'), - radix: 16, - ), - ); + HexColor(final String hexColor) : super(_parse(hexColor)); + + static int _parse(final String hexColor) { + final formated = hexColor.toUpperCase().replaceAll('#', '').padLeft(8, 'F'); + + return int.parse(formated, radix: 16); + } } diff --git a/packages/neon/neon/test/hex_color_test.dart b/packages/neon/neon/test/hex_color_test.dart new file mode 100644 index 00000000..c4166ebe --- /dev/null +++ b/packages/neon/neon/test/hex_color_test.dart @@ -0,0 +1,31 @@ +import 'package:flutter/material.dart'; +import 'package:neon/neon.dart'; +import 'package:test/test.dart'; + +void main() { + group('HexColor', () { + test('White', () { + final color = HexColor('#ffffffff'); + + expect(color.value, equals(Colors.white.value)); + }); + + test('Without alpha', () { + final color = HexColor('#ffffff'); + + expect(color.value, equals(Colors.white.value)); + }); + + test('Without #', () { + final color = HexColor('ffffffff'); + + expect(color.value, equals(Colors.white.value)); + }); + + test('Uppercase', () { + final color = HexColor('#FFFFFFFF'); + + expect(color.value, equals(Colors.white.value)); + }); + }); +}