Skip to content

Commit 2744b8f

Browse files
author
Christoph Bühler
committed
chore: move of stacked_core package
Signed-off-by: Christoph Bühler <[email protected]>
1 parent c7c3871 commit 2744b8f

18 files changed

+1246
-32
lines changed

CHANGELOG.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
## 1.2.4
2+
3+
- Add `instanceName` to DependencyRegistration annotations
4+
5+
## 1.2.3
6+
7+
- Add `bottomsheets` to StackedApp annotations
8+
9+
## 1.2.2
10+
11+
- Adds `autoTextFieldValidation` flag on FormView annotation
12+
13+
## 1.2.1
14+
15+
- Remove unused isPassword field from `FormTextField`
16+
17+
## 1.2.0
18+
19+
- Add `dialogs` to StackedApp annotations
20+
21+
## 1.1.0
22+
23+
- Add ambiguate function
24+
25+
## 1.0.0
26+
27+
- Initial version.

README.md

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,3 @@
1-
# New Package for Stacked
1+
# Stacked Core
22

3-
Created from the `package-template`.
4-
5-
After creating the repository, proceed with the following instructions:
6-
7-
- Update the repository settings to adhere to the conventions:
8-
- Allow squash&merge commits.
9-
- Suggest update.
10-
- Require linear history.
11-
- Add branch protection rules:
12-
- Require pull request reviews before merging.
13-
- Require status checks to pass before merging.
14-
- Allow the user with the DEPLOY token secret to overwrite pull request.
15-
- Create the flutter package with `flutter create -t package --project-name NAME .`
16-
- Update the content in the `README` file.
3+
This package contains all the code shared between our flutter and pure dart packages to avoid including flutter where it's not required.

analysis_options.yaml

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,30 @@
1-
include: package:flutter_lints/flutter.yaml
1+
# This file configures the static analysis results for your project (errors,
2+
# warnings, and lints).
3+
#
4+
# This enables the 'recommended' set of lints from `package:lints`.
5+
# This set helps identify many issues that may lead to problems when running
6+
# or consuming Dart code, and enforces writing Dart using a single, idiomatic
7+
# style and format.
8+
#
9+
# If you want a smaller set of lints you can change this to specify
10+
# 'package:lints/core.yaml'. These are just the most critical lints
11+
# (the recommended set includes the core lints).
12+
# The core lints are also what is used by pub.dev for scoring packages.
213

3-
# TODO: need the input of @FilledStacks here
4-
linter:
5-
rules:
6-
always_declare_return_types: true
7-
avoid_relative_lib_imports: true
8-
eol_at_end_of_file: true
9-
library_private_types_in_public_api: false
10-
lines_longer_than_80_chars: false
11-
prefer_final_fields: true
12-
prefer_final_in_for_each: true
13-
prefer_final_locals: true
14-
prefer_relative_imports: true
15-
prefer_single_quotes: true
14+
include: package:lints/recommended.yaml
1615

17-
analyzer:
18-
exclude:
19-
- '*.g.dart'
16+
# Uncomment the following section to specify additional rules.
17+
18+
# linter:
19+
# rules:
20+
# - camel_case_types
21+
22+
# analyzer:
23+
# exclude:
24+
# - path/to/excluded/files/**
25+
26+
# For more information about the core and recommended set of lints, see
27+
# https://dart.dev/go/core-lints
28+
29+
# For additional information about configuring this file, see
30+
# https://dart.dev/guides/language/analysis-options

example/example.dart

Whitespace-only changes.

example/stacked_core_example.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
void main() {}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/// This allows a value of type T or T?
2+
/// to be treated as a value of type T?.
3+
///
4+
/// We use this so that APIs that have become
5+
/// non-nullable can still be used with `!` and `?`
6+
/// to support older versions of the API as well.
7+
T? ambiguate<T>(T? value) => value;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/// Described the Bottomsheet functionality to generate in the app
2+
class StackedBottomsheet {
3+
/// Pass Bottomsheets types here.
4+
///
5+
/// bottomsheets classes should have two named parameters:
6+
/// 1. request of type [BottomsheetRequest]
7+
/// 2. completer of type [void Function(BottomsheetResponse)]
8+
final Type classType;
9+
10+
const StackedBottomsheet({
11+
required this.classType,
12+
});
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/// Described the Dialog functionality to generate in the app
2+
class StackedDialog {
3+
/// Pass Dialogs types here.
4+
///
5+
/// dialogs classes should have two named parameters:
6+
/// 1. request of type [DialogRequest]
7+
/// 2. completer of type [void Function(DialogResponse)]
8+
final Type classType;
9+
10+
const StackedDialog({
11+
required this.classType,
12+
});
13+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/// a simple filter function to be used inside [SimpleEnvironmentFilter]
2+
typedef EnvironmentFilterFunc = bool Function(Set<String>);
3+
const kEnvironmentsName = '__environments__';
4+
5+
/// filter for whether to register for the given set of environments
6+
/// clients can extend this class to maker
7+
/// their own environmentFilters
8+
abstract class EnvironmentFilter {
9+
/// holds passed environment keys
10+
/// to be used inside the filter or
11+
/// retrieved later by users
12+
final Set<String?> environments;
13+
14+
/// default constructor
15+
const EnvironmentFilter(this.environments);
16+
17+
/// This function is called before every
18+
/// registration call, if it returns true, the dependency
19+
/// will be registered otherwise, it will be ignored
20+
bool canRegister(Set<String> depEnvironments);
21+
}
22+
23+
/// A simple filter that can be used directly for simple use cases
24+
/// without having to extend the base [EnvironmentFilter]
25+
class SimpleEnvironmentFilter extends EnvironmentFilter {
26+
final EnvironmentFilterFunc filter;
27+
28+
const SimpleEnvironmentFilter(
29+
{required this.filter, Set<String> environments = const {}})
30+
: super(environments);
31+
32+
@override
33+
bool canRegister(Set<String> depEnvironments) => filter(depEnvironments);
34+
}
35+
36+
/// This filter validates dependencies with no environment
37+
/// keys or contain the provided [environment]
38+
class NoEnvOrContains extends EnvironmentFilter {
39+
NoEnvOrContains(String? environment) : super({environment});
40+
41+
@override
42+
bool canRegister(Set<String> depEnvironments) {
43+
return (depEnvironments.isEmpty) ||
44+
depEnvironments.contains(environments.first);
45+
}
46+
}
47+
48+
/// This filter validates dependencies with no environment
49+
/// keys, or the ones containing all the provided [environments]
50+
class NoEnvOrContainsAll extends EnvironmentFilter {
51+
const NoEnvOrContainsAll(Set<String> environments) : super(environments);
52+
53+
@override
54+
bool canRegister(Set<String> depEnvironments) {
55+
return (depEnvironments.isEmpty) ||
56+
depEnvironments.containsAll(environments);
57+
}
58+
}
59+
60+
/// This filter validates dependencies with no environment
61+
/// keys, or the ones containing one of the provided [environments]
62+
class NoEnvOrContainsAny extends EnvironmentFilter {
63+
const NoEnvOrContainsAny(Set<String> environments) : super(environments);
64+
65+
@override
66+
bool canRegister(Set<String> depEnvironments) {
67+
return (depEnvironments.isEmpty) ||
68+
depEnvironments.intersection(environments).isNotEmpty;
69+
}
70+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/// The annotation to be used for a view that contains a Form
2+
class FormView {
3+
/// The list of form fields to generate
4+
final List<FormField>? fields;
5+
6+
/// A flag to enable/disable auto validation of text fields. defauls to `true`
7+
final bool autoTextFieldValidation;
8+
const FormView({
9+
this.fields,
10+
this.autoTextFieldValidation = true,
11+
});
12+
}
13+
14+
/// Describes a form field to be generated
15+
class FormField {
16+
/// The name of the form field. This will be used to generate the Key mapping
17+
final String? name;
18+
19+
const FormField({this.name});
20+
}
21+
22+
/// Describes an entry field on the form that takes text
23+
class FormTextField extends FormField {
24+
/// Assigns initial value, `text` parameter in `TextEditingController`
25+
final String? initialValue;
26+
27+
final String? Function(String?)? validator;
28+
29+
/// Replace the default flutter [TextEditingController] with
30+
/// another controller that extends the [TextEditingController]
31+
///
32+
/// When providing this field [initialValue] will be ignored
33+
final dynamic Function()? customTextEditingController;
34+
35+
const FormTextField({
36+
String? name,
37+
this.initialValue,
38+
this.validator,
39+
this.customTextEditingController,
40+
}) : super(name: name);
41+
}
42+
43+
/// Describes a date form field.
44+
class FormDateField extends FormField {
45+
const FormDateField({String? name}) : super(name: name);
46+
}
47+
48+
class FormDropdownField extends FormField {
49+
final List<StaticDropdownItem> items;
50+
const FormDropdownField({String? name, required this.items})
51+
: super(name: name);
52+
}
53+
54+
class StaticDropdownItem {
55+
final String title;
56+
final String value;
57+
const StaticDropdownItem({required this.title, required this.value});
58+
}

0 commit comments

Comments
 (0)