Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace instanciate Color #440

Merged
merged 11 commits into from
Nov 30, 2021
87 changes: 35 additions & 52 deletions lib/components/atoms/color.dart
Original file line number Diff line number Diff line change
@@ -1,65 +1,48 @@
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

extension HexColor on Color {
static Color fromHex(String hexString) {
final buffer = StringBuffer();
if (hexString.length == 6 || hexString.length == 7) buffer.write('ff');
buffer.write(hexString.replaceFirst('#', ''));
return Color(int.parse(buffer.toString(), radix: 16));
}

static String toHex({required Color color, bool leadingHashSign = true}) =>
'${leadingHashSign ? '#' : ''}'
'${color.alpha.toRadixString(16).padLeft(2, '0')}'
'${color.red.toRadixString(16).padLeft(2, '0')}'
'${color.green.toRadixString(16).padLeft(2, '0')}'
'${color.blue.toRadixString(16).padLeft(2, '0')}';
}

class PilllColors {
const PilllColors();

static final Color primary = HexColor.fromHex("E56A45");
static final Color secondary = HexColor.fromHex("4E6287");
static final Color calendarHeader = HexColor.fromHex("B9D7F1");
static final Color accent = Colors.white;
static final Color pillSheet = HexColor.fromHex("E8EBED");
static final Color mat = HexColor.fromHex("FAFAFA").withAlpha(80);
static final Color sunday = HexColor.fromHex("E17F7F");
static final Color saturday = HexColor.fromHex("7FB9E1");
static final Color weekday = HexColor.fromHex("7E7E7E");
static final Color enable = HexColor.fromHex('E56A45');
static final Color disable = HexColor.fromHex("EAEAEA");
static final Color divider = HexColor.fromHex("9DAFBD");

static final Color bottomBar = HexColor.fromHex("FAFAFA");
static final Color border = HexColor.fromHex("DADADA");
static final Color unselect = HexColor.fromHex("DFDFDF");
static final Color background = HexColor.fromHex("F6F9FB");
static final Color blueBackground = HexColor.fromHex("F1F2F5");

static final Color blank = Colors.white;
static final Color black = HexColor.fromHex("333333");
static final Color red = HexColor.fromHex("EB5757");
static final Color potti = HexColor.fromHex("7C8E9C");
static final Color lightGray = HexColor.fromHex("CDCFD1");
static final Color gray = HexColor.fromHex("BEC0C2");
static final Color gold = HexColor.fromHex("B29446");

static final Color menstruation = HexColor.fromHex("E3BFC2");
static final Color duration = HexColor.fromHex("6A7DA5");
static const Color primary = Color(0xFFE56A45);
static const Color secondary = Color(0xFF4E6287);
static const Color calendarHeader = Color(0XFFB9D7F1);
static const Color accent = Colors.white;
static const Color pillSheet = Color(0xFFE8EBED);
static final Color mat = Color(0xFFFAFAFA).withAlpha(80);
static const Color sunday = Color(0xFFE17F7F);
static const Color saturday = Color(0xFF7FB9E1);
static const Color weekday = Color(0xFF7E7E7E);
static const Color enable = Color(0xFFE56A45);
static const Color disable = Color(0xFFEAEAEA);
static const Color divider = Color(0xFF9DAFBD);

static const Color bottomBar = Color(0xFFFAFAFA);
static const Color border = Color(0xFFDADADA);
static const Color unselect = Color(0xFFDFDFDF);
static const Color background = Color(0xFFF6F9FB);
static const Color blueBackground = Color(0xFFF1F2F5);

static const Color blank = Colors.white;
static const Color black = Color(0xFF333333);
static const Color red = Color(0xFFEB5757);
static const Color potti = Color(0xFF7C8E9C);
static const Color lightGray = Color(0xFFCDCFD1);
static const Color gray = Color(0xFFBEC0C2);
static const Color gold = Color(0xFFB29446);

static const Color menstruation = Color(0xFFE3BFC2);
static const Color duration = Color(0xFF6A7DA5);
static final Color overlay = primary.withAlpha(20);

static final Color modalBackground =
HexColor.fromHex("333333").withAlpha((255 * 0.7).round());
static final Color white = Colors.white;
Color(0xFF333333).withAlpha((255 * 0.7).round());
static const Color white = Colors.white;

static Color get disabledSheet => PilllColors.pillSheet;
static final Color thinSecondary = HexColor.fromHex("4E6287").withAlpha(20);
static final Color shadow = HexColor.fromHex("212121").withOpacity(0.14);
static final Color tinBackground =
HexColor.fromHex("212121").withOpacity(0.08);
static final Color thinSecondary = Color(0xFF4E6287).withAlpha(20);
static final Color shadow = Color(0xFF212121).withOpacity(0.14);
static final Color tinBackground = Color(0xFF212121).withOpacity(0.08);

static final Color appleBlack = HexColor.fromHex("231815");
static const Color appleBlack = Color(0xFF231815);
}
12 changes: 6 additions & 6 deletions lib/components/atoms/text_color.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ class TextColor {
static Color get standard => black;
static final Color black = Colors.black;
static final Color white = Colors.white;
static final Color darkGray = HexColor.fromHex("000000").withAlpha(153);
static final Color gray = HexColor.fromHex("7E7E7E");
static final Color lightGray = HexColor.fromHex("B1B1B1");
static final Color lightGray2 = HexColor.fromHex("666666");
static final Color noshime = HexColor.fromHex("3D4662");
static final Color darkGray = Color(0xFF000000).withAlpha(153);
static final Color gray = Color(0xFF7E7E7E);
static final Color lightGray = Color(0xFFB1B1B1);
static final Color lightGray2 = Color(0xFF666666);
static final Color noshime = Color(0xFF3D4662);
static final Color primary = PilllColors.primary;
static final Color main = HexColor.fromHex("29304D");
static final Color main = Color(0xFF29304D);
static final Color link = primary;
static final Color danger = PilllColors.red;
}
Expand Down
14 changes: 12 additions & 2 deletions lib/domain/calendar/calendar_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:pilll/analytics.dart';
import 'package:pilll/components/molecules/indicator.dart';
import 'package:pilll/domain/calendar/calendar_state.dart';
import 'package:pilll/domain/calendar/calendar_page_state.dart';
import 'package:pilll/domain/calendar/components/calendar_card.dart';
import 'package:pilll/components/atoms/color.dart';
import 'package:pilll/components/atoms/font.dart';
import 'package:pilll/components/atoms/text_color.dart';
import 'package:pilll/domain/calendar/components/pill_sheet_modified_history/pill_sheet_modified_history_card.dart';
import 'package:pilll/domain/home/home_page.dart';
import 'package:pilll/domain/calendar/calendar_store.dart';
import 'package:pilll/domain/calendar/calendar_page_store.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:pilll/error/universal_error_page.dart';

class CalendarPage extends HookWidget {
@override
Expand All @@ -21,6 +22,15 @@ class CalendarPage extends HookWidget {
final state = useProvider(calendarPageStateProvider.state);
homeKey.currentState?.diaries = state.diariesForMonth;

final exception = state.exception;
if (exception != null) {
return UniversalErrorPage(
error: exception,
child: null,
reload: () => store.reset(),
);
}

if (state.shouldShowIndicator) {
return ScaffoldIndicator();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'package:pilll/util/datetime/date_compare.dart';
import 'package:pilll/util/datetime/day.dart';
import 'package:pilll/util/formatter/date_time_formatter.dart';

part 'calendar_state.freezed.dart';
part 'calendar_page_state.freezed.dart';

@freezed
abstract class CalendarPageState implements _$CalendarPageState {
Expand All @@ -26,6 +26,7 @@ abstract class CalendarPageState implements _$CalendarPageState {
@Default(false) bool isPremium,
@Default(false) bool isTrial,
DateTime? trialDeadlineDate,
Object? exception,
}) = _CalendarPageState;

bool get shouldShowIndicator => isNotYetLoaded || setting == null;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading