FLUTTER ECOSYSTEM

mdg-soc-19/smooth-sort

Flutter용 멋지고 맞춤형 정렬 애니메이션입니다.

smooth-sort 프로젝트 이미지
Stars
33
Forks
3
최근 푸시(UTC)
2021. 4. 17.
프로젝트 상태
활성
Season of Code | MDG GitHub avatar
GITHUB Organization

Season of Code | MDG ↗

언어DartSwiftKotlinObjective-C

이 저장소가 배포한 패키지

사용 중인 의존성

의존성 목록 2 개
  • flutter{"sdk":"flutter"}
  • flutter_test개발 의존성{"sdk":"flutter"}

원본 README

아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.

README 펼치기 / 접기
https://raw.githubusercontent.com/mdg-soc-19/smooth-sort/master/smoothSortGifs/smooth_sort_cover.png

In today's world, developer's use now and then sorting in their mobile applications. For such developer's, Smooth Sort can become a useful package which provides wonderful and custom animation while sorting a list instead of reloading the app.

Explore how to use SmoothSort in your Flutter app through this medium blog.

Table of Contents

Installing

1. Depend on it

Add this to your package's pubspec.yaml file:

dependencies:
  smooth_sort: ^2.0.1
2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:smooth_sort/smooth_sort.dart';

Demo

Flip Vertically
animationType: flipVertically

https://raw.githubusercontent.com/mdg-soc-19/smooth-sort/master/smoothSortGifs/flipVertically.gif
Fade
animationType: fade

https://raw.githubusercontent.com/mdg-soc-19/smooth-sort/master/smoothSortGifs/fade.gif
Slide Right
animationType: slideRight

https://raw.githubusercontent.com/mdg-soc-19/smooth-sort/master/smoothSortGifs/slideRight.gif
Flip Horizontally
animationType: flipHorizontally

https://raw.githubusercontent.com/mdg-soc-19/smooth-sort/master/smoothSortGifs/flipHorizontally.gif
Scale
animationType: scale

https://raw.githubusercontent.com/mdg-soc-19/smooth-sort/master/smoothSortGifs/scale.gif
Slide Left
animationType: slideLeft

https://raw.githubusercontent.com/mdg-soc-19/smooth-sort/master/smoothSortGifs/slideLeft.gif
Reverse Flip Vertically
animationType: reverseFlipVertically

https://raw.githubusercontent.com/mdg-soc-19/smooth-sort/master/smoothSortGifs/reverseFlipVertically.gif
Reverse Flip Horizontally
animationType: reverseFlipHorizontally

https://raw.githubusercontent.com/mdg-soc-19/smooth-sort/master/smoothSortGifs/reverseFlipHorizontally.gif

Example in Medium blog

In the medium blog as well as the example app, I have implemented this animation for the shopping app for sorting the products through price using the Smooth Sort package.

Scale Animation

https://miro.medium.com/max/645/1*XXw6_7DBCmt9ULPy9DldGw.gif

Usage

For adding the SmoothSort in your Flutter app, you have to simply provide the options for ListView or GridView with the list of the widgets to be displayed in the list/grid with the another list of their corresponding itemIds.

For example: First create the object for SmoothSort

SmoothSort smoothSort = SmoothSort(
	listType: 'list',	 // specify the listType i.e. list or grid
	ascendant: true,	// sort ascending or descending
	itemList: [  
	  Container(  
	    color: Colors.red,  
	    alignment: Alignment.center,  
		child: Text(  
		    "A",  
	        style: TextStyle(fontSize: 150.0),  
		    ),  
	  ),  
	  Container(  
	    color: Colors.blueAccent,  
	    alignment: Alignment.center,  
	    child: Text(  
		    "B",  
	        style: TextStyle(fontSize: 150.0),  
			),  
	  ),  
	  Container(  
	    color: Colors.yellowAccent,  
	    alignment: Alignment.center,  
	    child: Text(  
		    "C",  
	        style: TextStyle(fontSize: 150.0),  
			),  
	  ),   
	],					// specify the list of widgets for the ListView/GridView
	itemIdList: [1, 2, 0],		// specify the corresponding ids for widgets	
	animationType: 'cardScale'	// specify the type of animation you want
);

Whenever you want to add the list or grid, just add the above widget as follows:

Column(  
  children: <Widget>[  
    smoothSort	// just add the SmoothSort object
  ],
),

After this, just call the smoothSort.onPress() method to start the animation for sorting the list/grid just like this:

RaisedButton(  
  child: Text("Sort"),  
  onPressed: () {  
    smoothSort.onPress();	// just call the onPress method
  },  
)

For more info, please refer to the main.dart in example.

Documentation

SmoothSort Class
Dart attribute Datatype Description Default Value
listType String Specifies the type of list i.e. list/grid. list
animationType String Specifies the type of animation required to sort the list/grid. flipVertically
itemList List<Widget> The list of widgets which is to be sorted. @required
itemIdList List<int> This list contains the ids for the corresponding widgets needed for the sorting of widgets. @required
gridCrossAxisCount int The number of grids in a single row in GridView. 2
ascendant bool Sort ascending or descending true

For help on editing package code, view the flutter documentation.

Algorithm

The algorithm used to build this project is as follows:

I have sorted the ListView or GridView with single TextView by using the default sort function by Dart language. On clicking of the sort button, I have provided different animations to the ListView or GridView according to the animation described by the user.

For more info, please refer to the smooth_sort.dart.

Bugs or Requests

If you encounter any problems feel free to open an issue. If you feel the library is
missing a feature, please raise a ticket on Github and I'll look into it.
Pull request are also welcome.

Contributors

Thanks goes to these awesome people! :blush:

https://avatars3.githubusercontent.com/u/40899882?s=400&u=8a8fa9a5fe3f883e9af17354a717308ef71157f1&v=4
Giulliano Albrecht
https://avatars.githubusercontent.com/u/5558549?s=400&u=8a8fa9a5fe3f883e9af17354a717308ef71157f1&v=4
Michael Dudek

License

SmoothSort is licensed under MIT license. View license.