Skip to main content

gloss_ui 0.1.2 copy "gloss_ui: ^0.1.2" to clipboard
gloss_ui: ^0.1.2 copied to clipboard

Skeuomorphic widgets for Flutter with glazed controls, recessed panels, accessible forms, navigation, and charts in coordinated light and dark themes.

example/lib/main.dart

// Simmer, a week of dinners set in Gloss: the look's Overview, then Today, Recipes, the shopping List and Settings,
// moved between by the look's own navigation (the bottom bar on a phone, the rail from 600, the sidebar from 1024).
// The Overview ends in the index of every part's page. A link opens it as the looks' galleries share:
// `/#/<page>?theme=dark&dir=rtl&text=200`, where the page is a part's page by its id (`buttons`, `fields`,
// `choices`...) or a screen by its name (`overview`, `home`, `recipes`, `shopping`, `settings`), or a scene of one
// (`/#/scene/recipe`, `filter`, `planner`, `deletePlan`, `search`, `searchNone`, `syncFailed`, `emptyList`);
// `theme=dark` at night, `dir=rtl` right to left, `text=200` the words at twice the size, `density=comfortable|compact`
// that density. `?slow=8` runs every animation eight times slower; `?a11y=1` turns the semantics on from the start;
// `?keylines=1` draws ui_core's keyline sheet over it.
import 'package:flutter/scheduler.dart' show timeDilation;
import 'package:flutter/widgets.dart';
import 'package:gloss_ui/gloss_ui.dart';
import 'package:ui_core_test/ui_core_test.dart';

import 'gallery_pages.dart';
import 'kit_gallery/simmer/simmer.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  // The face before the first frame: on the web the words never flash in a fallback face.
  await glossLoadFonts();
  final hash = Uri.base.fragment.startsWith('/')
      ? Uri.parse(Uri.base.fragment)
      : null;
  final query = {...Uri.base.queryParameters, ...?hash?.queryParameters};
  final segments =
      hash?.pathSegments.where((s) => s.isNotEmpty).toList() ??
      const <String>[];
  final (place, scene, part) = switch (segments) {
    ['scene', final name, ...] => (
      null,
      SimmerScene.values.where((s) => s.name == name).firstOrNull,
      null,
    ),
    [final id, ...] when galleryPages.any((p) => p.id == id) => (
      null,
      null,
      id,
    ),
    [final name, ...] => (
      SimmerPlace.values.where((p) => p.name == name).firstOrNull,
      null,
      null,
    ),
    _ => (null, null, null),
  };
  final text = double.tryParse(query['text'] ?? '');
  timeDilation = double.tryParse(query['slow'] ?? '') ?? 1;
  if (query['a11y'] == '1') WidgetsBinding.instance.ensureSemantics();
  final app = SimmerApp(
    initialPlace:
        place ??
        switch (scene) {
          null => SimmerPlace.overview,
          final scene => scene.place,
        },
    initialScene: scene,
    initialAppearance: query['theme'] == 'dark'
        ? SimmerAppearance.dark
        : SimmerAppearance.light,
    initialDirection: query['dir'] == 'rtl'
        ? TextDirection.rtl
        : TextDirection.ltr,
    initialDensity: switch (query['density']) {
      'comfortable' => GlossDensity.comfortable,
      'compact' => GlossDensity.compact,
      _ => null,
    },
    // `text=200` is a percentage, `text=2` a factor.
    textScale: text == null ? null : (text > 5 ? text / 100 : text),
    parts: [
      for (final page in galleryPages) (title: page.title, build: page.build),
    ],
    initialPart: switch (galleryPages.indexWhere((p) => p.id == part)) {
      -1 => null,
      final i => i,
    },
  );
  runApp(
    query['keylines'] == '1'
        ? Directionality(
            textDirection: TextDirection.ltr,
            child: DesignKeylineSheet(
              check: const DesignKeylineCheck(look: 'Gloss'),
              child: app,
            ),
          )
        : app,
  );
}
0
likes
160
points
--
downloads
screenshot

Documentation

API reference

Publisher

verified publisherwenkaifan.com

Weekly Downloads

Skeuomorphic widgets for Flutter with glazed controls, recessed panels, accessible forms, navigation, and charts in coordinated light and dark themes.

Homepage
Repository (GitHub)
View/report issues

Topics

#design-system #widget #ui #theme

License

BSD-3-Clause (license)

Dependencies

cupertino_ui, flutter, lucide_icons_flutter, material_ui, ui_core

More

Packages that depend on gloss_ui