import 'package:flutter/material.dart'; import '../../mews/document.dart'; /// The client's own presentation, mirroring the palettes of the default /// stylesheet mews-0.1.css (spec 5.1). Mews clients ignore author CSS and use /// their own, so these colors are the single visual source for page content. class MewsPalette { const MewsPalette({ required this.background, required this.foreground, required this.link, required this.visited, required this.border, required this.preBackground, }); final Color background; final Color foreground; final Color link; final Color visited; final Color border; final Color preBackground; } const _plainLight = MewsPalette( background: Color(0xfffaf8f3), foreground: Color(0xff1f1f1f), link: Color(0xff1a4f9c), visited: Color(0xff5b2a86), border: Color(0xffc9c4b8), preBackground: Color(0xffefece4), ); const _plainDark = MewsPalette( background: Color(0xff18191b), foreground: Color(0xffe3e1dc), link: Color(0xff8fb8f5), visited: Color(0xffc9a3f2), border: Color(0xff45464a), preBackground: Color(0xff222326), ); const _warmLight = MewsPalette( background: Color(0xfffbf4e8), foreground: Color(0xff2a2420), link: Color(0xff8a3d14), visited: Color(0xff5b2a86), border: Color(0xffc9c4b8), preBackground: Color(0xffefece4), ); const _warmDark = MewsPalette( background: Color(0xff1d1916), foreground: Color(0xffe8dfd3), link: Color(0xfff0b48a), visited: Color(0xffc9a3f2), border: Color(0xff45464a), preBackground: Color(0xff222326), ); const _coolLight = MewsPalette( background: Color(0xfff3f6fa), foreground: Color(0xff1c2430), link: Color(0xff1a4f9c), visited: Color(0xff5b2a86), border: Color(0xffc9c4b8), preBackground: Color(0xffefece4), ); const _coolDark = MewsPalette( background: Color(0xff161a20), foreground: Color(0xffdde4ee), link: Color(0xff8fb8f5), visited: Color(0xffc9a3f2), border: Color(0xff45464a), preBackground: Color(0xff222326), ); const _greenLight = MewsPalette( background: Color(0xfff2f6ef), foreground: Color(0xff1f2a1f), link: Color(0xff24502a), visited: Color(0xff5b2a86), border: Color(0xffc9c4b8), preBackground: Color(0xffefece4), ); const _greenDark = MewsPalette( background: Color(0xff161b16), foreground: Color(0xffdbe6d8), link: Color(0xff9fd39a), visited: Color(0xffc9a3f2), border: Color(0xff45464a), preBackground: Color(0xff222326), ); const _monoLight = MewsPalette( background: Color(0xffe8ebe1), foreground: Color(0xff1e2219), link: Color(0xff1e2219), visited: Color(0xff5b2a86), border: Color(0xffc9c4b8), preBackground: Color(0xffefece4), ); const _monoDark = MewsPalette( background: Color(0xff1b1d18), foreground: Color(0xffc8d0b8), link: Color(0xffc8d0b8), visited: Color(0xffc9a3f2), border: Color(0xff45464a), preBackground: Color(0xff222326), ); /// Resolves the palette: the reader's variant choice overrides the page's own /// variant unless the choice is "site" (spec 5.3, 8.2). MewsPalette paletteFor({required MewsVariant pageVariant, required String readerVariant, required bool dark}) { final variant = readerVariant == 'site' ? pageVariant.name : pageVariantFromName(readerVariant); return switch ((variant, dark)) { (MewsVariant.warm, false) => _warmLight, (MewsVariant.warm, true) => _warmDark, (MewsVariant.cool, false) => _coolLight, (MewsVariant.cool, true) => _coolDark, (MewsVariant.green, false) => _greenLight, (MewsVariant.green, true) => _greenDark, (MewsVariant.mono, false) => _monoLight, (MewsVariant.mono, true) => _monoDark, (_, false) => _plainLight, (_, true) => _plainDark, }; } MewsVariant pageVariantFromName(String name) => switch (name) { 'warm' => MewsVariant.warm, 'cool' => MewsVariant.cool, 'green' => MewsVariant.green, 'mono' => MewsVariant.mono, _ => MewsVariant.plain, };