kashi 0.1.0
kashi: ^0.1.0 copied to clipboard
Kashi for Flutter: the Persian, RTL-first design system. Material themes from Kashi's tokens, the Kashi typeface, a Jalali date picker and Persian fields (national ID, card, IBAN, mobile, price).
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:kashi/kashi.dart';
void main() => runApp(const KashiExample());
class KashiExample extends StatefulWidget {
const KashiExample({super.key});
@override
State<KashiExample> createState() => _KashiExampleState();
}
class _KashiExampleState extends State<KashiExample> {
var _mode = ThemeMode.light;
var _en = false;
@override
Widget build(BuildContext context) => MaterialApp(
title: 'Kashi for Flutter',
debugShowCheckedModeBanner: false,
theme: KashiTheme.light(),
darkTheme: KashiTheme.dark(),
themeMode: _mode,
locale: Locale(_en ? 'en' : 'fa'),
supportedLocales: const [Locale('fa'), Locale('en')],
localizationsDelegates: GlobalMaterialLocalizations.delegates,
home: Builder(builder: (context) {
final k = context.kashi, t = Theme.of(context).textTheme;
return Scaffold(
appBar: AppBar(
title: Text(_en ? 'Kashi for Flutter' : 'کاشی برای Flutter'),
actions: [
IconButton(tooltip: 'fa / en', onPressed: () => setState(() => _en = !_en), icon: const Icon(Icons.translate)),
IconButton(
tooltip: _en ? 'Theme' : 'تم',
onPressed: () => setState(() => _mode = _mode == ThemeMode.light ? ThemeMode.dark : ThemeMode.light),
icon: Icon(_mode == ThemeMode.light ? Icons.dark_mode_outlined : Icons.light_mode_outlined),
),
],
),
body: Center(
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 440),
child: ListView(padding: const EdgeInsets.all(KashiSpace.s5), children: [
Text(_en ? 'Checkout' : 'پرداخت', style: t.headlineMedium),
const SizedBox(height: KashiSpace.s1),
Text(_en ? 'Persian fields, the Jalali calendar and the Kashi typeface.' : 'فیلدهای فارسی، تقویم شمسی و فونت کاشی، با همان توکنهای وب.', style: t.bodyMedium!.copyWith(color: k.textSecondary)),
const SizedBox(height: KashiSpace.s6),
const NationalIdField(initialValue: '0013542419'),
const SizedBox(height: KashiSpace.s4),
const MobileField(),
const SizedBox(height: KashiSpace.s4),
const CardNumberField(initialValue: '6037991234567893'),
const SizedBox(height: KashiSpace.s4),
const IbanField(),
const SizedBox(height: KashiSpace.s4),
const PriceField(initialValue: 1250000),
const SizedBox(height: KashiSpace.s4),
JalaliDateField(label: _en ? 'Delivery date' : 'تاریخ تحویل', firstDate: DateTime.now()),
const SizedBox(height: KashiSpace.s6),
KashiCard(title: _en ? 'Calendar' : 'تقویم', description: _en ? 'Fridays and holidays in red' : 'جمعهها و تعطیلات قرمزند', child: Center(child: JalaliCalendar(selected: DateTime.now(), persianDigits: !_en))),
const SizedBox(height: KashiSpace.s6),
Row(children: [KashiButton(variant: KashiButtonVariant.primary, label: _en ? 'Pay' : 'پرداخت', onPressed: () {}), const SizedBox(width: KashiSpace.s3), KashiButton(label: _en ? 'Cancel' : 'انصراف', onPressed: () {})]),
]),
),
),
);
}),
);
}