knt_ui 1.0.0 knt_ui: ^1.0.0 copied to clipboard
A Flutter package contains all handy widgets for Appixi's future projects
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:knt_ui/knt_ui.dart';
import 'generated/assets.gen.dart';
import 'generated/locale_keys.g.dart';
import 'kntgen/generated_page.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await EasyLocalization.ensureInitialized();
EasyLocalization.logger.enableBuildModes = [];
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return KntAppWrapper(
supportedLocales: const [Locale(DefinedSetting.defaultLanguageCode)],
debugShowPreviewDevice: false,
appBuilder: (context, devicePreviewLocale, devicePreviewAppBuilder) {
return MaterialApp(
title: 'Flutter Demo',
locale: devicePreviewLocale,
localizationsDelegates: context.localizationDelegates,
supportedLocales: context.supportedLocales,
builder: devicePreviewAppBuilder,
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
},
);
}
}
abstract class TabIconMain {
static final TabIcon home = TabIcon(
localeKeyTitle: LocaleKeys.main_tabs_home,
activeImagePath: Assets.images.icHomeTabActive.path,
inactiveImagePath: Assets.images.icHomeTabUnactive.path,
);
static final TabIcon help = TabIcon(
localeKeyTitle: LocaleKeys.main_tabs_help,
activeImagePath: Assets.images.icHelpTabActive.path,
inactiveImagePath: Assets.images.icHelpTabUnactive.path,
);
static final List<TabIcon> values = [home, help];
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage>
with SingleTickerProviderStateMixin {
final _onTabChanged = ValueNotifier<int>(0);
@override
Widget build(BuildContext context) {
return KntBottomNavScaffold(
onTabChanged: _onTabChanged,
appBar: KntAppBar(titlePage: 'KNT demo'),
icons: TabIconMain.values,
tabs: [
Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
KntButton(
title: LocaleKeys.main_navigate_web.tr(),
onPressed: () {
KntWebPage.push(
context,
url: 'www.google.com',
);
},
),
KntButton(
title: LocaleKeys.main_navigate_tabHelp.tr(),
onPressed: () {
_onTabChanged.value = 1;
},
),
KntButton(
title: LocaleKeys.main_navigate_generatedPage.tr(),
onPressed: () {
GeneratedPage.push(context);
},
),
KntButton(
title: 'Show Toast',
onPressed: () => context.onError('Show fucking noobs!'),
),
const KntDefaultIssuingWidget(
errorMessage: 'Abc',
),
const KntChip(text: 'abc'),
KntDefaultImage(
width: 64.w,
height: 64.w,
),
const KntImage.network(
uri:
'https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Ftse1.mm.bing.net%2Fth%3Fid%3DOIP.uIgI--NBV7O7HCKmv5Ab2gHaFh%26pid%3DApi&f=1',
),
],
),
),
Container(
color: Colors.orange,
),
],
);
}
}