Skip to content

Commit 0c78b06

Browse files
authored
Release 0.10.0 (#25)
1 parent d366305 commit 0c78b06

Some content is hidden

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

41 files changed

+425
-357
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## [0.10.0]
4+
5+
* Migrating to `bloc` 8.0.x and `flutter_bloc` 8.0.x,
6+
37
## [0.9.0] * Breaking Changes *
48

59
* Migrating to `bloc` 7.0.0 and `flutter_bloc` 7.0.1,

README.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ A `Repository` to handles data operations. It knows where to get the data from a
1818

1919
* `onReady` - informs the presentation layer that view is in it's initial state, and no action has taken place yet,
2020
* `onLoading` - informs the presentation layer that the data is being loaded, so it can display a loading indicator,
21-
* `onRefreshing` - informs the presentation layer that the data is being refreshed, so it can display a refresh indicator or/and the current state of list elements,
21+
* `onRefreshing` - informs the presentation layer that the data is being refreshed, so it can display a refresh indicator or/and the current state of list items,
2222
* `onSuccess` - informs the presentation layer that the loading is completed and a `nonnull` and not empty data was retrieved,
2323
* `onEmpty` - informs the presentation layer that the loading is completed, but `null` or empty data was retrieved,
2424
* `onError` - informs the presentation layer that the loading or refreshing has ended with an error. It also provides an error that has occurred.
@@ -36,7 +36,7 @@ A `Repository` to handles data operations. It knows where to get the data from a
3636
## Features
3737

3838
### ListBloc
39-
The most basic use case. Allows to fetch, refresh and display a list of elements without filtering and pagination. Thus, `ListBloc` should be used only with a reasonable amount of data. `ListBloc` provides the methods for loading and refreshing data: `loadElements()` and `refreshElements()`. The former is most suitable for initial data fetch or for retry action when the first fetch fails. The latter is designed for being called after the initial fetch succeeds. It can be performed when the list has already been loaded. To display the current view state `ListBloc` cooperates with `BlocBuilder` as well as `ViewStateBuilder`.
39+
The most basic use case. Allows to fetch, refresh and display a list of items without filtering and pagination. Thus, `ListBloc` should be used only with a reasonable amount of data. `ListBloc` provides the methods for loading and refreshing data: `loaditems()` and `refreshitems()`. The former is most suitable for initial data fetch or for retry action when the first fetch fails. The latter is designed for being called after the initial fetch succeeds. It can be performed when the list has already been loaded. To display the current view state `ListBloc` cooperates with `BlocBuilder` as well as `ViewStateBuilder`.
4040

4141
##### ListRepository
4242

@@ -45,7 +45,7 @@ A `ListRepository` implementation should provide only one method:
4545
`Future<List<T>> getAll();` - this method is responsible for providing all the data to the `ListBloc`.
4646

4747
Where:
48-
* `T` is the element type returned by this repository.
48+
* `T` is the item type returned by this repository.
4949

5050
##### Usage
5151

@@ -58,11 +58,11 @@ An extension to the `ListBloc` that allows filtering.
5858

5959
`FilterListRepository` provides two methods:
6060

61-
`Future<List<T>> getAll();` - this method is called when a `null` filter is provided and should return all elements,
62-
`Future<List<T>> getBy(F filter);` - this method is called with `nonnull` filter and should return only elements that match it.
61+
`Future<List<T>> getAll();` - this method is called when a `null` filter is provided and should return all items,
62+
`Future<List<T>> getBy(F filter);` - this method is called with `nonnull` filter and should return only items that match it.
6363

6464
Where:
65-
* `T` is the element type returned by this repository,
65+
* `T` is the item type returned by this repository,
6666
* `F` is the filter type, which can be primitive as well as complex object.
6767

6868
#### Usage
@@ -76,16 +76,16 @@ A list BLoC with pagination but without filtering. It works best with [Infinite
7676
Contains information about the current page, this is `number` and `size`.
7777

7878
#### PagedList
79-
List of elements with information if there are more elements or not.
79+
List of items with information if there are more items or not.
8080

8181
#### PagedListRepository
8282
`PagedListRepository` comes with only one method:
8383

84-
`Future<List<T>> getAll(Page page);` - this method retrieves elements meeting the pagination restriction provided by the `page` object.
85-
When elements are exceeded it should return an empty list or throw `PageNotFoundException`. `PagedListBloc` will handle both cases in the same way.
84+
`Future<List<T>> getAll(Page page);` - this method retrieves items meeting the pagination restriction provided by the `page` object.
85+
When items are exceeded it should return an empty list or throw `PageNotFoundException`. `PagedListBloc` will handle both cases in the same way.
8686

8787
Where:
88-
* `T` is the element type returned by this repository.
88+
* `T` is the item type returned by this repository.
8989

9090
#### Usage
9191

@@ -98,34 +98,34 @@ A list BLoC with pagination and filtering. It works best with [Infinite Widgets]
9898
Contains information about the current page, this is `number` and `size`.
9999

100100
#### PagedList
101-
List of elements with information if there are more elements or not.
101+
List of items with information if there are more items or not.
102102

103103
#### PagedListFilterRepository
104104
`PagedListFilterRepository` provides only two methods:
105105

106-
`Future<List<T>> getAll(Page page);` - retrieves elements meeting the pagination restriction provided by the `page` object.
107-
`Future<List<T>> getBy(Page page, F filter);` - retrieves elements meeting pagination as well as the filter restrictions provided by the `page` and `filter` objects.
106+
`Future<List<T>> getAll(Page page);` - retrieves items meeting the pagination restriction provided by the `page` object.
107+
`Future<List<T>> getBy(Page page, F filter);` - retrieves items meeting pagination as well as the filter restrictions provided by the `page` and `filter` objects.
108108

109-
When elements are exceeded it should return an empty list or throw `PageNotFoundException`. `PagedListFilterBloc` will handle both cases in the same way.
109+
When items are exceeded it should return an empty list or throw `PageNotFoundException`. `PagedListFilterBloc` will handle both cases in the same way.
110110

111111
Where:
112-
* `T` is the element type returned by this repository,
112+
* `T` is the item type returned by this repository,
113113
* `F` is the filter type, which can be primitive as well as complex object.
114114

115115
#### Usage
116116

117117
[Paged List BLoC Sample App](example/lib/src/list_paged_filter_app.dart)
118118

119119
### DetailsBloc
120-
A BLoC that allows to fetch a single element with given identifier.
120+
A BLoC that allows to fetch a single item with given identifier.
121121

122122
#### DetailsRepository
123123
`DetailsRepository` comes with only one method:
124124

125-
`Future<T> getById(I id);` - this method retrieves an element with given id. When there's no element matching the id the `null` should be returned or `ElementNotFoundException` should be thrown. In both cases the `DetailsBloc` will emit `Empty` state.
125+
`Future<T> getById(I id);` - this method retrieves an item with given id. When there's no item matching the id the `null` should be returned or `itemNotFoundException` should be thrown. In both cases the `DetailsBloc` will emit `Empty` state.
126126

127127
Where:
128-
* `T` is the element type returned by this repository,
128+
* `T` is the item type returned by this repository,
129129
* `I` is the id type, it can be primitive as well as a complex object.
130130

131131
#### Usage:

example/android/app/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ apply plugin: 'kotlin-android'
2626
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
2727

2828
android {
29-
compileSdkVersion 28
29+
compileSdkVersion 32
3030

3131
sourceSets {
3232
main.java.srcDirs += 'src/main/kotlin'
@@ -37,7 +37,7 @@ android {
3737
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
3838
applicationId "pl.karollisiewicz.bloc.example"
3939
minSdkVersion 16
40-
targetSdkVersion 28
40+
targetSdkVersion 32
4141
versionCode flutterVersionCode.toInteger()
4242
versionName flutterVersionName
4343
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
@@ -62,6 +62,6 @@ flutter {
6262
dependencies {
6363
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
6464
testImplementation 'junit:junit:4.12'
65-
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
66-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
65+
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
66+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
6767
}
Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
22
package="pl.karollisiewicz.bloc.example">
33

4-
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
5-
calls FlutterMain.startInitialization(this); in its onCreate method.
6-
In most cases you can leave this as-is, but you if you want to provide
7-
additional functionality it is fine to subclass or reimplement
8-
FlutterApplication and put your custom class here. -->
4+
<uses-permission android:name="android.permission.INTERNET" />
5+
96
<application
10-
android:name="io.flutter.app.FlutterApplication"
7+
android:name="${applicationName}"
118
android:label="example"
129
android:icon="@mipmap/ic_launcher">
1310
<activity
@@ -16,18 +13,22 @@
1613
android:theme="@style/LaunchTheme"
1714
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
1815
android:hardwareAccelerated="true"
19-
android:windowSoftInputMode="adjustResize">
20-
<!-- This keeps the window background of the activity showing
21-
until Flutter renders its first frame. It can be removed if
22-
there is no splash screen (such as the default splash screen
23-
defined in @style/LaunchTheme). -->
16+
android:windowSoftInputMode="adjustResize"
17+
android:exported="true">
18+
2419
<meta-data
25-
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
26-
android:value="true" />
20+
android:name="io.flutter.embedding.android.NormalTheme"
21+
android:resource="@style/NormalTheme" />
22+
2723
<intent-filter>
2824
<action android:name="android.intent.action.MAIN"/>
2925
<category android:name="android.intent.category.LAUNCHER"/>
3026
</intent-filter>
3127
</activity>
28+
<!-- Don't delete the meta-data below.
29+
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
30+
<meta-data
31+
android:name="flutterEmbedding"
32+
android:value="2" />
3233
</application>
3334
</manifest>
Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
package pl.karollisiewicz.bloc.example
22

3-
import android.os.Bundle
3+
import io.flutter.embedding.android.FlutterActivity;
44

5-
import io.flutter.app.FlutterActivity
6-
import io.flutter.plugins.GeneratedPluginRegistrant
7-
8-
class MainActivity: FlutterActivity() {
9-
override fun onCreate(savedInstanceState: Bundle?) {
10-
super.onCreate(savedInstanceState)
11-
GeneratedPluginRegistrant.registerWith(this)
12-
}
13-
}
5+
class MainActivity: FlutterActivity()
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
33
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
4-
<!-- Show a splash screen on the activity. Automatically removed when
5-
Flutter draws its first frame -->
64
<item name="android:windowBackground">@drawable/launch_background</item>
75
</style>
6+
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
7+
<item name="android:windowBackground">?android:colorBackground</item>
8+
</style>
89
</resources>

example/android/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
buildscript {
2-
ext.kotlin_version = '1.3.40'
2+
ext.kotlin_version = '1.7.10'
33
repositories {
44
google()
5-
jcenter()
5+
mavenCentral()
66
}
77

88
dependencies {
9-
classpath 'com.android.tools.build:gradle:7.1.1'
9+
classpath 'com.android.tools.build:gradle:7.2.1'
1010
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1111
}
1212
}
1313

1414
allprojects {
1515
repositories {
1616
google()
17-
jcenter()
17+
mavenCentral()
1818
}
1919
}
2020

example/android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip

example/lib/src/album/ui/photos_list_paged.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ class PhotosListPaged extends StatelessWidget {
1717
@override
1818
Widget build(BuildContext context) {
1919
return InfiniteListView.separated(
20-
itemBuilder: (context, index) => _PhotoGridItem(page.elements[index]),
20+
itemBuilder: (context, index) => _PhotoGridItem(page.items[index]),
2121
separatorBuilder: (context, index) => const Divider(),
22-
itemCount: page.elements.length,
23-
hasNext: page.hasMoreElements,
22+
itemCount: page.items.length,
23+
hasNext: page.hasMoreItems,
2424
nextData: onLoadNextPage,
2525
loadingWidget: const LoadingPageIndicator(),
2626
);

example/lib/src/list_app.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class _PostsPageState extends State<PostsPage> {
3636
@override
3737
void initState() {
3838
super.initState();
39-
listBloc = BlocProvider.of<ListBloc<Post>>(context)..loadElements();
39+
listBloc = BlocProvider.of<ListBloc<Post>>(context)..loadItems();
4040
}
4141

4242
@override
@@ -56,5 +56,5 @@ class _PostsPageState extends State<PostsPage> {
5656
);
5757
}
5858

59-
void _refreshPosts() => listBloc.refreshElements();
59+
void _refreshPosts() => listBloc.refreshItems();
6060
}

0 commit comments

Comments
 (0)