Skip to content

Commit bfc2cee

Browse files
committed
Initial package commit
1 parent 9e7ef78 commit bfc2cee

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+63857
-6
lines changed

.gitignore

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,3 @@
44
.packages
55
.pub/
66
build/
7-
# If you're building an application, you may want to check-in your pubspec.lock
8-
pubspec.lock
9-
10-
# Directory created by dartdoc
11-
# If you don't generate documentation locally you can remove this line.
12-
doc/api/

analysis_options.yaml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
analyzer:
2+
strong-mode: true
3+
linter:
4+
rules:
5+
# - always_declare_return_types
6+
# - always_put_control_body_on_new_line
7+
- always_put_required_named_parameters_first
8+
- always_require_non_null_named_parameters
9+
# - always_specify_types
10+
- annotate_overrides
11+
- avoid_annotating_with_dynamic
12+
- avoid_as
13+
- avoid_catches_without_on_clauses
14+
- avoid_catching_errors
15+
- avoid_classes_with_only_static_members
16+
- avoid_empty_else
17+
- avoid_function_literals_in_foreach_calls
18+
- avoid_init_to_null
19+
- avoid_null_checks_in_equality_operators
20+
- avoid_positional_boolean_parameters
21+
- avoid_return_types_on_setters
22+
- avoid_returning_null
23+
- avoid_returning_this
24+
- avoid_setters_without_getters
25+
- avoid_slow_async_io
26+
- avoid_types_on_closure_parameters
27+
- await_only_futures
28+
- camel_case_types
29+
- cancel_subscriptions
30+
- cascade_invocations
31+
- close_sinks
32+
- comment_references
33+
- constant_identifier_names
34+
- control_flow_in_finally
35+
- directives_ordering
36+
- empty_catches
37+
- empty_constructor_bodies
38+
- empty_statements
39+
- hash_and_equals
40+
- implementation_imports
41+
- invariant_booleans
42+
- iterable_contains_unrelated_type
43+
- join_return_with_assignment
44+
- library_names
45+
- library_prefixes
46+
- list_remove_unrelated_type
47+
- literal_only_boolean_expressions
48+
- no_adjacent_strings_in_list
49+
- no_duplicate_case_values
50+
# - non_constant_identifier_names
51+
- omit_local_variable_types
52+
- one_member_abstracts
53+
- only_throw_errors
54+
- overridden_fields
55+
- package_api_docs
56+
- package_names
57+
- package_prefixed_library_names
58+
- parameter_assignments
59+
- prefer_adjacent_string_concatenation
60+
- prefer_asserts_in_initializer_lists
61+
- prefer_collection_literals
62+
- prefer_conditional_assignment
63+
- prefer_const_constructors
64+
- prefer_const_constructors_in_immutables
65+
- prefer_constructors_over_static_methods
66+
- prefer_contains
67+
# - prefer_expression_function_bodies
68+
# - prefer_final_fields
69+
# - prefer_final_locals
70+
- prefer_foreach
71+
- prefer_function_declarations_over_variables
72+
- prefer_initializing_formals
73+
- prefer_interpolation_to_compose_strings
74+
- prefer_is_empty
75+
- prefer_is_not_empty
76+
- prefer_single_quotes
77+
# - public_member_api_docs
78+
- recursive_getters
79+
- slash_for_doc_comments
80+
- sort_constructors_first
81+
- sort_unnamed_constructors_first
82+
- super_goes_last
83+
- test_types_in_equals
84+
- throw_in_finally
85+
# - type_annotate_public_apis
86+
- type_init_formals
87+
- unawaited_futures
88+
- unnecessary_brace_in_string_interps
89+
- unnecessary_getters_setters
90+
- unnecessary_lambdas
91+
- unnecessary_null_aware_assignments
92+
- unnecessary_null_in_if_null_operators
93+
- unnecessary_overrides
94+
- unnecessary_this
95+
- unrelated_type_equality_checks
96+
- use_rethrow_when_possible
97+
- use_setters_to_change_properties
98+
- use_string_buffers
99+
- use_to_and_as_if_applicable
100+
- valid_regexps

lib/src/app.dart

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import 'package:over_react/over_react.dart';
2+
3+
import 'package:verter/src/data.dart';
4+
import 'package:verter/src/components/switcher.dart';
5+
6+
@Factory()
7+
UiFactory<AppProps> App;
8+
9+
@Props()
10+
class AppProps extends UiProps {
11+
Data data;
12+
}
13+
14+
@Component()
15+
class AppComponent extends UiComponent<AppProps> {
16+
@override
17+
render() {
18+
if (props.data == null) return false;
19+
20+
return Dom.div()(
21+
_renderDayChange(),
22+
_renderFiatPrices(),
23+
_renderCryptoPrices(),
24+
_renderIcons(),
25+
);
26+
}
27+
28+
ReactElement _renderDayChange() {
29+
return (Dom.div()
30+
..className = 'row'
31+
)('24hr change: ${props.data.dayChange}%');
32+
}
33+
34+
ReactElement _renderFiatPrices() {
35+
return (Switcher()
36+
..className = 'row'
37+
..prices = [
38+
'\$ ${props.data.usdPrice}',
39+
'€ ${props.data.eurPrice}',
40+
]
41+
)();
42+
}
43+
44+
ReactElement _renderCryptoPrices() {
45+
return (Switcher()
46+
..className = 'row'
47+
..prices = [
48+
'\u20BF ${props.data.btcPrice}',
49+
'\u039E ${props.data.ethPrice}',
50+
'\u0141 ${props.data.ltcPrice}',
51+
'\u01B5 ${props.data.zecPrice}',
52+
'${props.data.satPrice} Satoshi',
53+
]
54+
)();
55+
}
56+
57+
ReactElement _renderIcons() {
58+
return (Dom.div()
59+
..className = 'row row--icons'
60+
)(
61+
(Dom.a()
62+
..target = '_blank'
63+
..rel = 'noopener noreferrer'
64+
..href = 'https://vertcoin.org/'
65+
)(
66+
(Dom.img()
67+
..className = 'fa fa-vertcoin fa-2'
68+
..src = '/img/icon.png'
69+
)(),
70+
),
71+
(Dom.a()
72+
..target = '_blank'
73+
..rel = 'noopener noreferrer'
74+
..href = 'https://www.reddit.com/r/vertcoin'
75+
)(
76+
(Dom.i()..className = 'fa fa-reddit-square fa-2')()
77+
),
78+
(Dom.a()
79+
..target = '_blank'
80+
..rel = 'noopener noreferrer'
81+
..href = 'https://twitter.com/vertcoin'
82+
)(
83+
(Dom.i()..className = 'fa fa-twitter-square fa-2')()
84+
),
85+
);
86+
}
87+
}

lib/src/components/switcher.dart

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import 'package:over_react/over_react.dart';
2+
3+
import 'package:verter/src/components/switcher_primitive.dart';
4+
5+
@Factory()
6+
UiFactory<SwitcherProps> Switcher;
7+
8+
@Props()
9+
class SwitcherProps extends UiProps {
10+
List<String> prices;
11+
}
12+
13+
@State()
14+
class SwitcherState extends UiState {
15+
String price;
16+
}
17+
18+
@Component()
19+
class SwitcherComponent extends UiStatefulComponent<SwitcherProps, SwitcherState> {
20+
@override
21+
Map getDefaultProps() => (newProps()
22+
..prices = const []
23+
);
24+
25+
@override
26+
Map getInitialState() => (newState()
27+
..price = props.prices.first
28+
);
29+
30+
@override
31+
render() {
32+
return (SwitcherPrimitive()
33+
..addProps(copyUnconsumedProps())
34+
..price = state.price
35+
..onNextButtonClick = _handleNextButtonClick
36+
..onPrevButtonClick = _handlePrevButtonClick
37+
)();
38+
}
39+
40+
void _handleNextButtonClick(_) {
41+
if (props.prices.length == 2) {
42+
if (state.price == props.prices.last) {
43+
setState(newState()
44+
..price = props.prices.first
45+
);
46+
} else {
47+
setState(newState()
48+
..price = props.prices.last
49+
);
50+
}
51+
} else if (state.price == props.prices.last) {
52+
setState(newState()
53+
..price = props.prices.first
54+
);
55+
} else {
56+
setState(newState()
57+
..price = props.prices[props.prices.indexOf(state.price) + 1]
58+
);
59+
}
60+
}
61+
62+
void _handlePrevButtonClick(_) {
63+
if (props.prices.length == 2) {
64+
if (state.price == props.prices.last) {
65+
setState(newState()
66+
..price = props.prices.first
67+
);
68+
} else {
69+
setState(newState()
70+
..price = props.prices.last
71+
);
72+
}
73+
} else if (state.price == props.prices.first) {
74+
setState(newState()
75+
..price = props.prices.last
76+
);
77+
} else {
78+
setState(newState()
79+
..price = props.prices[props.prices.indexOf(state.price) - 1]
80+
);
81+
}
82+
}
83+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import 'package:over_react/over_react.dart';
2+
3+
@Factory()
4+
UiFactory<SwitcherPrimitiveProps> SwitcherPrimitive;
5+
6+
@Props()
7+
class SwitcherPrimitiveProps extends UiProps {
8+
String price;
9+
DomEventCallback onPrevButtonClick;
10+
DomEventCallback onNextButtonClick;
11+
}
12+
13+
@Component()
14+
class SwitcherPrimitiveComponent extends UiComponent<SwitcherPrimitiveProps> {
15+
@override
16+
render() {
17+
return (Dom.div()..addProps(copyUnconsumedDomProps()))(
18+
_renderPrevButton(),
19+
_renderView(),
20+
_renderNextButton(),
21+
);
22+
}
23+
24+
ReactElement _renderPrevButton() {
25+
return (Dom.button()
26+
..className = 'float-left btn'
27+
..onClick = props.onPrevButtonClick
28+
)(
29+
(Dom.i()..className = 'fa fa-chevron-left fa-1')(),
30+
);
31+
}
32+
33+
ReactElement _renderView() {
34+
return (Dom.span()..className = 'price')(
35+
props.price
36+
);
37+
}
38+
39+
ReactElement _renderNextButton() {
40+
return (Dom.button()
41+
..className = 'float-right btn'
42+
..onClick = props.onNextButtonClick
43+
)(
44+
(Dom.i()..className = 'fa fa-chevron-right fa-1')(),
45+
);
46+
}
47+
}

lib/src/data.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Data {
2+
final String eurPrice;
3+
final String usdPrice;
4+
final String btcPrice;
5+
final String ltcPrice;
6+
final String ethPrice;
7+
final String zecPrice;
8+
final String satPrice;
9+
final String dayChange;
10+
11+
Data({this.eurPrice, this.usdPrice, this.btcPrice, this.ltcPrice, this.ethPrice, this.zecPrice, this.satPrice, this.dayChange});
12+
}

lib/verter.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export './src/app.dart';
2+
export './src/data.dart';

0 commit comments

Comments
 (0)