Skip to content

Commit

Permalink
Precommit hooks, readme updates
Browse files Browse the repository at this point in the history
  • Loading branch information
faiyyazs committed Aug 29, 2022
1 parent 76cce8b commit c2c4719
Show file tree
Hide file tree
Showing 29 changed files with 50 additions and 48 deletions.
29 changes: 21 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Here are some things you need to prepare before this Boilerplate setup:
3. Visual Studio Code (Optional) [Install](https://code.visualstudio.com/)
4. **Dart** and **Flutter** extensions:
- **Intellij Platform** users ([Dart](https://plugins.jetbrains.com/plugin/6351-dart), [Flutter](https://plugins.jetbrains.com/plugin/9212-flutter) )
- **Visual Studio Code** users ([Dart](https://marketplace.visualstudio.com/items?itemName=Dart-Code.dart-code), [Flutter](https://marketplace.visualstudio.com /items?itemName=Dart-Code.flutter) )
- **Visual Studio Code** users ([Dart](https://marketplace.visualstudio.com/items?itemName=Dart-Code.dart-code), [Flutter](https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter) )

#### Setup

Expand Down Expand Up @@ -87,17 +87,23 @@ Sensitive information like api keys, credentials, etc should not be checked into

#### Get Dependencies

```
```bash
flutter pub get
```

#### Run Code Generation

```bash
bash app/scripts/generate-all.sh
```
bash scripts/generate-all.sh

#### Setup Hooks

```bash
bash app/scripts/setup-hooks.sh
```

Read the [scripts documentation](app/scripts/README.md) to learn about all the scrips used in the project.
Read the [scripts documentation](app/scripts/README.md) to learn about all the scripts used in the project.



Expand Down Expand Up @@ -144,7 +150,7 @@ You can setup any environment specific values in the respective `main.dart` file

To run a specific flavor you need to specify the flavor and target file.

```sh
```bash
flutter run --flavor qa -t lib/entrypoints/main_qa.dart
```

Expand Down Expand Up @@ -197,6 +203,11 @@ In Visual Studio Code, navigate to `Preferences` -> `Settings` and search for `F
- [Localisation](./localisation/)
- Routing/Navigations
- [Responsive Framework](./wiki/responsive-framework/RESPONSIVE_FRAMEWORK.md)
- Pre-commit Checks
- Dart Analysis
- [Dart Fix](https://github.com/dart-lang/sdk/blob/main/pkg/dartdev/doc/dart-fix.md)
- Flutter Format




Expand Down Expand Up @@ -267,7 +278,7 @@ For the android CD workflow to run, we need to perform the following setup steps
- Follow these instructions to [generate an upload keystore](https://developer.android.com/studio/publish/app-signing#generate-key). Note down the `store password`, `key alias` and `key password`. You will need these in later steps.
- Use `openssl` to convert the `jks` file to `Base64`.

```
```bash
openssl base64 < app_key.jks | tr -d '\n' | tee app_key_encoded.txt
```

Expand Down Expand Up @@ -305,7 +316,8 @@ We will divide the guide into steps so that it is easier to understand
- Replace `PROVISIONING PROFILE NAME` with your Provisioning Profile Name (You already created one in Step 2, use that)
- Replace `TEAM_ID` with your team id. Look at [this](https://stackoverflow.com/a/18727947) answer on "How to find your Team ID"

<summary><i>Click to View Template</i></summary>
<details>
<summary><i>Click to View Template</i></summary>

```xml
<?xml version="1.0" encoding="UTF-8"?>
Expand Down Expand Up @@ -338,6 +350,7 @@ We will divide the guide into steps so that it is easier to understand
</dict>
</plist>
```

</details>

Create a new file called `options.plist` and save the above contents in that file
Expand All @@ -364,7 +377,7 @@ We will divide the guide into steps so that it is easier to understand

- To generate a base64 string, use the following command, replacing `FILENAME` with your filename

```
```bash
openssl base64 < FILENAME | tr -d '\n' | tee ENCODED_FILENAME.txt
```

Expand Down
1 change: 0 additions & 1 deletion app/lib/di/states/viewmodels.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';

import '../../dependencies.dart';


final splashViewModelProvider =
ChangeNotifierProvider.autoDispose<SplashViewModel>(
(ref) => SplashViewModel(getIt.get<String>(instanceName: "BaseUrl")),
Expand Down
2 changes: 1 addition & 1 deletion app/lib/entrypoints/main_prod.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ void main() {
),
);
startApp();
}
}
1 change: 1 addition & 0 deletions app/lib/feature/splash/splash_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class SplashPage extends BasePage<SplashViewModel> {
}

class SplashPageState extends BaseStatefulPage<SplashViewModel, SplashPage> {
@override
ProviderBase provideBase() {
return splashViewModelProvider;
}
Expand Down
7 changes: 2 additions & 5 deletions app/lib/feature/splash/splash_page_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@ import 'package:injectable/injectable.dart';

@injectable
class SplashViewModel extends BasePageViewModel {

final String myBaseUrl;

SplashViewModel(@factoryParam this.myBaseUrl){
print("My First log in Splash ${this.myBaseUrl}");
SplashViewModel(@factoryParam this.myBaseUrl) {
print("My First log in Splash $myBaseUrl");
}


}
1 change: 0 additions & 1 deletion app/lib/feature/splash/splash_page_view.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:statemanagement_riverpod/statemanagement_riverpod.dart';

Expand Down
2 changes: 1 addition & 1 deletion app/lib/flavors/flavor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ enum Flavor {
dev,
qa,
prod,
}
}
1 change: 0 additions & 1 deletion app/lib/flavors/flavor_values.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@ class FlavorValues {

bool get logSqlStatements => _logSqlStatements;
}

2 changes: 1 addition & 1 deletion app/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ import 'package:app/entrypoints/main_dev.dart' as entrypoint;
/// until a fix is released.
void main() {
entrypoint.main();
}
}
13 changes: 9 additions & 4 deletions app/lib/myapp.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,24 @@ class MyApp extends StatelessWidget {
Widget build(BuildContext context) {
return ThemeBuilder(
themes: [
ThemeData(backgroundColor: Colors.red, accentColor: Colors.blue),
ThemeData(
backgroundColor: Colors.red,
colorScheme:
ColorScheme.fromSwatch().copyWith(secondary: Colors.blue)),
],
darkTheme: ThemeData(
brightness: Brightness.dark,
backgroundColor: Colors.blue[700],
accentColor: Colors.yellow[700],
colorScheme:
ColorScheme.fromSwatch().copyWith(secondary: Colors.yellow[700]),
),
lightTheme: ThemeData(
brightness: Brightness.light,
backgroundColor: Colors.blue[300],
accentColor: Colors.yellow[300],
colorScheme:
ColorScheme.fromSwatch().copyWith(secondary: Colors.yellow[300]),
),
builder: (context, regularTheme, darkTheme, themeMode) => MaterialApp(
builder: (context, regularTheme, darkTheme, themeMode) => MaterialApp(
navigatorKey: AppService.navigatorKey,
builder: (context, widget) => ResponsiveWrapper.builder(
ClampingScrollWrapper.builder(context, widget!),
Expand Down
2 changes: 1 addition & 1 deletion app/lib/navigation/app_router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class AppRouter {
switch (settings.name) {
case RoutePaths.Splash:
return CupertinoPageRoute(
builder: (context) => SplashPage(),
builder: (context) => const SplashPage(),
settings: const RouteSettings(name: RoutePaths.Splash));

default:
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/hooks/pre-commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ else
echo "Static analysis failed. Running dart fix."
dart fix --apply
echo "Static analysis failed. Running flutter format"
flutter format lib
flutter format app/lib
exit 1
fi
2 changes: 1 addition & 1 deletion app/scripts/setup-hooks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ echo All hooks marked as executable

echo Moving all hooks to .git/hooks/

rsync -P scripts/hooks/* .git/hooks/
rsync -P app/scripts/hooks/* .git/hooks/
1 change: 0 additions & 1 deletion core/data/example/data_example.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:data/data.dart';

void main() {

Expand Down
1 change: 0 additions & 1 deletion core/data/test/data_test.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:data/data.dart';
import 'package:test/test.dart';

void main() {
Expand Down
1 change: 0 additions & 1 deletion core/domain/example/domain_example.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:domain/domain.dart';

void main() {

Expand Down
2 changes: 1 addition & 1 deletion core/domain/lib/src/usecase/base/params.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:shared/shared.dart';
abstract class Params {
final bool reloading;

Params({this.reloading: false});
Params({this.reloading = false});

Either<AppError, bool> verify();
}
1 change: 0 additions & 1 deletion core/domain/test/domain_test.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:domain/domain.dart';
import 'package:test/test.dart';

void main() {
Expand Down
2 changes: 1 addition & 1 deletion core/shared/lib/src/model/error/database_error.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class DatabaseError extends BaseError {

@override
String getFriendlyMessage() {
return "${error.message}";
return error.message;
}

@override
Expand Down
4 changes: 2 additions & 2 deletions core/shared/lib/src/model/error/network_error.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import 'base_error.dart';
class NetworkError extends BaseError {
NetworkError({
required int httpError,
String message: "",
String message = "",
required Exception cause,
}) : super(error: ErrorInfo(code: httpError, message: message), cause: cause);

@override
String getFriendlyMessage() {
return "${this.error.message}";
return error.message;
}

@override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:dependency_injection/dependency_injection.dart';

void main() {

Expand Down
1 change: 0 additions & 1 deletion localisation/example/localisation_example.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:localisation/strings.dart';

void main() {

Expand Down
2 changes: 0 additions & 2 deletions localisation/test/localisation_test.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'package:localisation/strings.dart';
import 'package:test/test.dart';

void main() {

Expand Down
1 change: 0 additions & 1 deletion services/test/services_test.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:services/services.dart';
import 'package:test/test.dart';

void main() {
Expand Down
2 changes: 1 addition & 1 deletion statemanagement-core/lib/src/base_page_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ abstract class CoreBasePageState<VM, T extends StatefulWidget> extends State<T>
backgroundColor: scaffoldBackgroundColor(),
appBar: buildAppbar(),
extendBodyBehindAppBar: extendBodyBehindAppBar(),
body: buildScaffoldBody(context, _viewModel!),
body: buildScaffoldBody(context, _viewModel as VM),
drawer: buildDrawer(),
drawerEnableOpenDragGesture: drawerEnableOpenDragGesture(),
bottomNavigationBar: buildBottomNavigationBar(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:statemanagement_riverpod/statemanagement_riverpod.dart';

void main() {

Expand Down
2 changes: 1 addition & 1 deletion statemanagement-riverpod/lib/src/base_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ abstract class BasePageViewWidget<T extends BasePageViewModel> extends Widget {

@override
DataProviderElement<T> createElement() =>
DataProviderElement<T>(this, this.providerBase);
DataProviderElement<T>(this, providerBase);
}

class DataProviderElement<T extends BasePageViewModel>
Expand Down
1 change: 0 additions & 1 deletion themes/example/themes_example.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:themes/src/theme_manager.dart';

void main() {

Expand Down
10 changes: 5 additions & 5 deletions themes/lib/src/theme_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class ThemeManager {
int? get selectedThemeIndex {
if (themes != null && themes!.isNotEmpty) {
int? themeIndex = _sharedPreferences.themeIndex;
return themeIndex == null ? 0 : themeIndex;
return themeIndex ?? 0;
}
return null;
}
Expand All @@ -86,7 +86,7 @@ class ThemeManager {
var hasMultipleThemes = themes != null && themes!.length > 1;
var hasLightAndDarkThemes = darkTheme != null && lightTheme != null;
assert(hasMultipleThemes || hasLightAndDarkThemes,
'''You have to supply themes if you want to use themes. You have supplied no themes. Don\'t do that. Supply themes.
'''You have to supply themes if you want to use themes. You have supplied no themes. Don't do that. Supply themes.
You can supply either a list of ThemeData objects to the themes property or a lightTheme and a darkTheme to be swapped between.
''');

Expand Down Expand Up @@ -128,13 +128,13 @@ You can supply either a list of ThemeData objects to the themes property or a li
updateOverlayColors(selectedTheme);
}

ThemeModel _currTheme = ThemeModel(
ThemeModel currTheme = ThemeModel(
selectedTheme: selectedTheme,
darkTheme: darkTheme,
themeMode: _selectedThemeMode);

_themesController = BehaviorSubject<ThemeModel>.seeded(_currTheme);
_initialTheme = _currTheme;
_themesController = BehaviorSubject<ThemeModel>.seeded(currTheme);
_initialTheme = currTheme;

ThemeService.getInstance().setThemeManager(this);
}
Expand Down

0 comments on commit c2c4719

Please sign in to comment.