feat: Initialize project
This commit is contained in:
85
lib/ui/views/home/home_view.dart
Normal file
85
lib/ui/views/home/home_view.dart
Normal file
@@ -0,0 +1,85 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:bahla_front/ui/common/app_colors.dart';
|
||||
import 'package:bahla_front/ui/common/ui_helpers.dart';
|
||||
|
||||
import 'home_viewmodel.dart';
|
||||
|
||||
class HomeView extends StackedView<HomeViewModel> {
|
||||
const HomeView({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget builder(
|
||||
BuildContext context,
|
||||
HomeViewModel viewModel,
|
||||
Widget? child,
|
||||
) {
|
||||
return Scaffold(
|
||||
body: SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 25.0),
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
verticalSpaceLarge,
|
||||
Column(
|
||||
children: [
|
||||
const Text(
|
||||
'Hello, STACKED!',
|
||||
style: TextStyle(
|
||||
fontSize: 35,
|
||||
fontWeight: FontWeight.w900,
|
||||
),
|
||||
),
|
||||
verticalSpaceMedium,
|
||||
MaterialButton(
|
||||
color: Colors.black,
|
||||
onPressed: viewModel.incrementCounter,
|
||||
child: Text(
|
||||
viewModel.counterLabel,
|
||||
style: const TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
MaterialButton(
|
||||
color: kcDarkGreyColor,
|
||||
onPressed: viewModel.showDialog,
|
||||
child: const Text(
|
||||
'Show Dialog',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
MaterialButton(
|
||||
color: kcDarkGreyColor,
|
||||
onPressed: viewModel.showBottomSheet,
|
||||
child: const Text(
|
||||
'Show Bottom Sheet',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
HomeViewModel viewModelBuilder(
|
||||
BuildContext context,
|
||||
) =>
|
||||
HomeViewModel();
|
||||
}
|
||||
36
lib/ui/views/home/home_viewmodel.dart
Normal file
36
lib/ui/views/home/home_viewmodel.dart
Normal file
@@ -0,0 +1,36 @@
|
||||
import 'package:bahla_front/app/app.bottomsheets.dart';
|
||||
import 'package:bahla_front/app/app.dialogs.dart';
|
||||
import 'package:bahla_front/app/app.locator.dart';
|
||||
import 'package:bahla_front/ui/common/app_strings.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:stacked_services/stacked_services.dart';
|
||||
|
||||
class HomeViewModel extends BaseViewModel {
|
||||
final _dialogService = locator<DialogService>();
|
||||
final _bottomSheetService = locator<BottomSheetService>();
|
||||
|
||||
String get counterLabel => 'Counter is: $_counter';
|
||||
|
||||
int _counter = 0;
|
||||
|
||||
void incrementCounter() {
|
||||
_counter++;
|
||||
rebuildUi();
|
||||
}
|
||||
|
||||
void showDialog() {
|
||||
_dialogService.showCustomDialog(
|
||||
variant: DialogType.infoAlert,
|
||||
title: 'Stacked Rocks!',
|
||||
description: 'Give stacked $_counter stars on Github',
|
||||
);
|
||||
}
|
||||
|
||||
void showBottomSheet() {
|
||||
_bottomSheetService.showCustomSheet(
|
||||
variant: BottomSheetType.notice,
|
||||
title: ksHomeBottomSheetTitle,
|
||||
description: ksHomeBottomSheetDescription,
|
||||
);
|
||||
}
|
||||
}
|
||||
56
lib/ui/views/startup/startup_view.dart
Normal file
56
lib/ui/views/startup/startup_view.dart
Normal file
@@ -0,0 +1,56 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:bahla_front/ui/common/ui_helpers.dart';
|
||||
|
||||
import 'startup_viewmodel.dart';
|
||||
|
||||
class StartupView extends StackedView<StartupViewModel> {
|
||||
const StartupView({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget builder(
|
||||
BuildContext context,
|
||||
StartupViewModel viewModel,
|
||||
Widget? child,
|
||||
) {
|
||||
return const Scaffold(
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
'STACKED',
|
||||
style: TextStyle(fontSize: 40, fontWeight: FontWeight.w900),
|
||||
),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text('Loading ...', style: TextStyle(fontSize: 16)),
|
||||
horizontalSpaceSmall,
|
||||
SizedBox(
|
||||
width: 16,
|
||||
height: 16,
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
strokeWidth: 6,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
StartupViewModel viewModelBuilder(
|
||||
BuildContext context,
|
||||
) =>
|
||||
StartupViewModel();
|
||||
|
||||
@override
|
||||
void onViewModelReady(StartupViewModel viewModel) => SchedulerBinding.instance
|
||||
.addPostFrameCallback((timeStamp) => viewModel.runStartupLogic());
|
||||
}
|
||||
18
lib/ui/views/startup/startup_viewmodel.dart
Normal file
18
lib/ui/views/startup/startup_viewmodel.dart
Normal file
@@ -0,0 +1,18 @@
|
||||
import 'package:stacked/stacked.dart';
|
||||
import 'package:bahla_front/app/app.locator.dart';
|
||||
import 'package:bahla_front/app/app.router.dart';
|
||||
import 'package:stacked_services/stacked_services.dart';
|
||||
|
||||
class StartupViewModel extends BaseViewModel {
|
||||
final _navigationService = locator<NavigationService>();
|
||||
|
||||
// Place anything here that needs to happen before we get into the application
|
||||
Future runStartupLogic() async {
|
||||
await Future.delayed(const Duration(seconds: 3));
|
||||
|
||||
// This is where you can make decisions on where your app should navigate when
|
||||
// you have custom startup logic
|
||||
|
||||
_navigationService.replaceWithHomeView();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user