1653804000
Copy from official ReorderableListView
Usage:
dependencies:
reorderable_grid_view: ^2.2.2
Example
class _MyHomePageState extends State<MyHomePage> {
final data = [1, 2, 3, 4, 5];
@override
Widget build(BuildContext context) {
Widget buildItem(String text) {
return Card(
key: ValueKey(text),
child: Text(text),
);
}
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
// use ReorderableGridView.count() when version >= 2.0.0
// else use ReorderableGridView()
child: ReorderableGridView.count(
crossAxisSpacing: 10,
mainAxisSpacing: 10,
crossAxisCount: 3,
children: this.data.map((e) => buildItem("$e")).toList(),
onReorder: (oldIndex, newIndex) {
setState(() {
final element = data.removeAt(oldIndex);
data.insert(newIndex, element);
});
},
footer: [
Card(
child: Center(
child: Icon(Icons.add),
),
),
],
),
),
);
}
}
Other
ReorderableGridView.builder
and ReorderableSliverGridView.count
can work.
Important
as issue #17 says. There's some broken api in MultiDragGestureRecognizer. So if you have some issue relative to MultiDragGestureRecognizer.
Please try both 1.1.x and 1.2.x version.
TODO
Run this command:
With Flutter:
$ flutter pub add reorderable_grid_view
This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get
):
dependencies:
reorderable_grid_view: ^2.2.2
Alternatively, your editor might support flutter pub get
. Check the docs for your editor to learn more.
Now in your Dart code, you can use:
import 'package:reorderable_grid_view/reorderable_grid_view.dart';
example/lib/main.dart
import 'package:example/demo_grid_builder.dart';
import 'package:example/demo_grid_sliver.dart';
import 'package:example/test_issue_24.dart';
import 'package:example/test_overlay.dart';
import 'package:flutter/material.dart';
import 'package:reorderable_grid_view/reorderable_grid_view.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
// home: Scaffold(
// body: DemoReorderableGrid(),
// ),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key? key, this.title}) : super(key: key);
final String? title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
// return TestIssue24();
return DefaultTabController(
length: 4,
child: Scaffold(
appBar: AppBar(
bottom: TabBar(
tabs: [
Tab(
text: "Grid.count",
),
Tab(
text: "Grid.build",
),
Tab(
text: "SliverGrid.count",
),
Tab(
text: "Test Overlay",
)
],
),
title: Text(widget.title!),
),
body: TabBarView(
children: [
DemoReorderableGrid(),
DemoGridBuilder(),
DemoGridSliver(),
TestIssue24()
],
),
),
);
}
}
class DemoReorderableGrid extends StatefulWidget {
@override
_DemoReorderableGridState createState() => _DemoReorderableGridState();
}
class _DemoReorderableGridState extends State<DemoReorderableGrid> {
final data = List<int>.generate(10, (index) => index);
double scrollSpeedVariable = 5;
@override
Widget build(BuildContext context) {
return Padding(
padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
child: Center(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child: ReorderableGridView.count(
crossAxisSpacing: 10,
mainAxisSpacing: 10,
crossAxisCount: 3,
childAspectRatio: 0.6, // 0 < childAspectRatio <= 1.0
children: this.data.map((e) => buildItem(e)).toList(),
scrollSpeedController:
(int timeInMilliSecond, double overSize, double itemSize) {
// print(
// "timeInMilliSecond: $timeInMilliSecond, overSize: $overSize, itemSize $itemSize");
if (timeInMilliSecond > 1500) {
scrollSpeedVariable = 15;
} else {
scrollSpeedVariable = 5;
}
return scrollSpeedVariable;
},
onReorder: (oldIndex, newIndex) {
// print("reorder: $oldIndex -> $newIndex");
setState(() {
final element = data.removeAt(oldIndex);
data.insert(newIndex, element);
});
},
dragWidgetBuilder: (index, child) {
return Card(
color: Colors.blue,
child: Text(index.toString()),
);
},
footer: [
Card(
child: Center(
child: Icon(Icons.add),
),
),
],
),
),
);
}
Widget buildItem(int index) {
return Card(
key: ValueKey(index),
child: Text(index.toString()),
);
}
}
Author: huhuang03
Source code: https://github.com/huhuang03/reorderable_grid_view
License: MIT license
1653804000
Copy from official ReorderableListView
Usage:
dependencies:
reorderable_grid_view: ^2.2.2
Example
class _MyHomePageState extends State<MyHomePage> {
final data = [1, 2, 3, 4, 5];
@override
Widget build(BuildContext context) {
Widget buildItem(String text) {
return Card(
key: ValueKey(text),
child: Text(text),
);
}
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
// use ReorderableGridView.count() when version >= 2.0.0
// else use ReorderableGridView()
child: ReorderableGridView.count(
crossAxisSpacing: 10,
mainAxisSpacing: 10,
crossAxisCount: 3,
children: this.data.map((e) => buildItem("$e")).toList(),
onReorder: (oldIndex, newIndex) {
setState(() {
final element = data.removeAt(oldIndex);
data.insert(newIndex, element);
});
},
footer: [
Card(
child: Center(
child: Icon(Icons.add),
),
),
],
),
),
);
}
}
Other
ReorderableGridView.builder
and ReorderableSliverGridView.count
can work.
Important
as issue #17 says. There's some broken api in MultiDragGestureRecognizer. So if you have some issue relative to MultiDragGestureRecognizer.
Please try both 1.1.x and 1.2.x version.
TODO
Run this command:
With Flutter:
$ flutter pub add reorderable_grid_view
This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get
):
dependencies:
reorderable_grid_view: ^2.2.2
Alternatively, your editor might support flutter pub get
. Check the docs for your editor to learn more.
Now in your Dart code, you can use:
import 'package:reorderable_grid_view/reorderable_grid_view.dart';
example/lib/main.dart
import 'package:example/demo_grid_builder.dart';
import 'package:example/demo_grid_sliver.dart';
import 'package:example/test_issue_24.dart';
import 'package:example/test_overlay.dart';
import 'package:flutter/material.dart';
import 'package:reorderable_grid_view/reorderable_grid_view.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
// home: Scaffold(
// body: DemoReorderableGrid(),
// ),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key? key, this.title}) : super(key: key);
final String? title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
// return TestIssue24();
return DefaultTabController(
length: 4,
child: Scaffold(
appBar: AppBar(
bottom: TabBar(
tabs: [
Tab(
text: "Grid.count",
),
Tab(
text: "Grid.build",
),
Tab(
text: "SliverGrid.count",
),
Tab(
text: "Test Overlay",
)
],
),
title: Text(widget.title!),
),
body: TabBarView(
children: [
DemoReorderableGrid(),
DemoGridBuilder(),
DemoGridSliver(),
TestIssue24()
],
),
),
);
}
}
class DemoReorderableGrid extends StatefulWidget {
@override
_DemoReorderableGridState createState() => _DemoReorderableGridState();
}
class _DemoReorderableGridState extends State<DemoReorderableGrid> {
final data = List<int>.generate(10, (index) => index);
double scrollSpeedVariable = 5;
@override
Widget build(BuildContext context) {
return Padding(
padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
child: Center(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child: ReorderableGridView.count(
crossAxisSpacing: 10,
mainAxisSpacing: 10,
crossAxisCount: 3,
childAspectRatio: 0.6, // 0 < childAspectRatio <= 1.0
children: this.data.map((e) => buildItem(e)).toList(),
scrollSpeedController:
(int timeInMilliSecond, double overSize, double itemSize) {
// print(
// "timeInMilliSecond: $timeInMilliSecond, overSize: $overSize, itemSize $itemSize");
if (timeInMilliSecond > 1500) {
scrollSpeedVariable = 15;
} else {
scrollSpeedVariable = 5;
}
return scrollSpeedVariable;
},
onReorder: (oldIndex, newIndex) {
// print("reorder: $oldIndex -> $newIndex");
setState(() {
final element = data.removeAt(oldIndex);
data.insert(newIndex, element);
});
},
dragWidgetBuilder: (index, child) {
return Card(
color: Colors.blue,
child: Text(index.toString()),
);
},
footer: [
Card(
child: Center(
child: Icon(Icons.add),
),
),
],
),
),
);
}
Widget buildItem(int index) {
return Card(
key: ValueKey(index),
child: Text(index.toString()),
);
}
}
Author: huhuang03
Source code: https://github.com/huhuang03/reorderable_grid_view
License: MIT license
1596475108
NumPy consists of different methods to duplicate an original array. The two main functions for this duplication are copy and view. The duplication of the array means an array assignment. When we duplicate the original array, the changes made in the new array may or may not reflect. The duplicate array may use the same location or may be at a new memory location.
It returns a copy of the original array stored at a new location. The copy doesn’t share data or memory with the original array. The modifications are not reflected. The copy function is also known as deep copy.
import numpy as np
arr = np.array([20,30,50,70])
a= arr.copy()
#changing a value in original array
arr[0] = 100
print(arr)
print(a)
Output
[100 30 50 70]
[20 30 50 70]
Changes made in the original array are not reflected in the copy.
import numpy as np
arr = np.array([20,30,50,70])
a= arr.copy()
#changing a value in copy array
a[0] = 5
print(arr)
print(a)
Output
[20 30 50 70]
[ 5 30 50 70]
Changes made in copy are not reflected in the original array
#numpy tutorials #numpy copy #numpy views #numpy
1655906400
Monotone is a Modern Mobile Application, integrated with powerful Unsplash API provided by Unsplash. It implemented almost all features including viewing, searching, collecting photos. And other features, such as profile, license, FAQ are supported as well.
This is an un-official application, exploring the feasibility of some conceptions is the goal of this project. Written in Swift, triggered by RxSwift, draw responsive constraints using SnapKit.
If you like this project or inspired by any ideas of this project, please star it without any hesitation. (ヽ(✿゚▽゚)ノ)
Currently supported tasks:
Position | Module | Page | Style & Layout | Powered by Data | Animation Effects | Localization |
---|---|---|---|---|---|---|
Main | Login | Sign Up & Sign In | ✅ | ✅ | ✅ | ✅ |
Photo | List (Search & Topic) | ✅ | ✅ | ✅ | ✅ | |
View | ✅ | ✅ | ✅ | ✅ | ||
Camera Settings | ✅ | ✅ | ✅ | ✅ | ||
Collect (Add & Remove) | ✅ | ✅ | ✅ | ✅ | ||
Share to SNS | ✅ | ⬜️ | ✅ | ✅ | ||
Save to Album | ✅ | ✅ | ✅ | ✅ | ||
Side Menu | Profile | Details | ✅ | ✅ | ✅ | ✅ |
Menu | My Photos | ✅ | ✅ | ✅ | ✅ | |
Hiring | ✅ | ⬜️ | ✅ | ✅ | ||
Licenses | ✅ | ✅ | ✅ | ✅ | ||
Help | ✅ | ⬜️ | ✅ | ✅ | ||
Made with Unsplash | ✅ | ⬜️ | ✅ | ✅ | ||
Tab Bar | Store | Home | ✅ | ⬜️ | ✅ | ✅ |
Details | ✅ | ⬜️ | ✅ | ✅ | ||
Wallpaper | List (Adapt Screen Size) | ✅ | ⬜️ | ✅ | ✅ | |
Collection | List | ✅ | ✅ | ✅ | ✅ | |
Explore | List (Photo & Collection) | ✅ | ⬜️ | ✅ | ✅ |
This application uses Cocoapods
to manage dependencies. Please refer to Cocoapods Offical Website to install & configure(If you already installed Cocoapods
, skip this).
Monotone is trigged by Unsplash API . The very first thing must be done is applying a pair of OAuth key to run it.
Redirect URI & Permissions - Redirect URI
section, input monotone://unsplash
, make sure all authentication options are checked, just like the image shown below.# Clone to a local folder
git clone https://github.com/Neko3000/Monotone.git
# Direct to Project folder
cd Monotone
# Install Pods
pod install
config_debug.json
file,and rename it to config.json
(This file is ignored by .gitignore);config.json
,input your ”Access Key“ and ”Secret Key“,they will be copyed to APP folder when running.(For more information, please refer to the content in Project->Build Phases->Run Script and APPCredential.swift );Project | Description |
---|---|
RxSwift | Framework for Reactive Async Programming. |
Action | Based on RxSwift,encapsulate actions for calling。 |
DataSources | Based on RxSwift,extend logic interaction of tableview and collectionview。 |
Alamofire | HTTP network library. |
SwiftyJSON | Handle JSON format data effectively. |
ObjectMapper | Map data between models and JSON. |
Kingfisher | Network image cache libray with many functions. |
SnapKit | Make constraints effectively. |
... | ... |
For more information,please check Podfile。
The basic structure of this project.
Monotone
├── Monotone
│ ├── /Vars #Global Variables
│ ├── /Enums #Enums (Includes some dummy data)
│ ├── /Application
│ │ ├── AppCredential #Authentication Credential
│ │ ...
│ │ └── UserManager #User Managment
│ ├── /Utils #Utils
│ │ ├── /BlurHash #Photo Hash
│ │ ├── ColorPalette #Global Colors
│ │ ├── AnimatorTrigger #Animation Effects
│ │ └── MessageCenter #Message Notification
│ │── /Extension #Extensions
│ │── /Services #Services
│ │ ├── /Authentication #Requests of Authentication
│ │ └── /Network #Requesets of Data
│ │── /Components #View Classes
│ │── /ViewModels #View Models
│ │── /ViewControllers #View Controllers
│ │── /Models #Data Models
│ │── /Coordinators #Segues
│ └── /Resource #Resource
└── Pods
Designing
The interface you are seeing are all designed by Addie Design Co. They shared this document, everyone can free download it and use it. Those design elements and their level of completion are astonishing. This application would not be here without this design document.
Thanks again to Addie Design Co and this beautiful design document.
Unsplash is a website dedicated to sharing high-quality stock photography under the Unsplash license. All photos uploaded by photographers will be organized and archived by editors.
And this website is one of my favorites, admired for its artistic, the spirit of sharing.
You will find my home page here. (Not updated frequently since 2020)
Limited by data Unsplash API provides, some parts of this application only finished their styles and layouts(Almost in store, explore, etc). If the API provides more detailed data on these parts in the future, we will add new features as soon as possible.
Meanwhile, focusing on the current application, we will improve it continuously.
If you are an experienced mobile application developer and want to improve this application. You are welcomed to participate in this open-source project. Practice your ideas, improve even refactor this application.
Follow standard steps:
Fork
this repo;Branch
(git checkout -b feature/AmazingFeature
);Commit
(git commit -m 'Add some AmazingFeature'
);Push
to remote Branch
(git push origin feature/AmazingFeature
);Pull Request
.For anyone, open an issue if you find any problems. PRs are welcome.
Author: Neko3000
Source code: https://github.com/Neko3000/Monotone
License: MIT license
1669174554
In this article, we will learn how to replace elements in Python NumPy Array. To replace elements in Python NumPy Array, We can follow the following examples.
The following code shows how to replace all elements in the NumPy array equal to 8 with a new value of 20:
#replace all elements equal to 8 with 20
my_array[my_array == 8] = 20
#view updated array
print(my_array)
[ 4 5 5 7 20 20 9 12]
The following code shows how to replace all elements in the NumPy array greater than 8 with a new value of 20:
#replace all elements greater than 8 with 20
my_array[my_array > 8] = 20
#view updated array
print(my_array)
[ 4 5 5 7 8 8 20 20]
The following code shows how to replace all elements in the NumPy array greater than 8 or less than 6 with a new value of 20:
#replace all elements greater than 8 or less than 6 with a new value of 20
my_array[(my_array > 8) | (my_array < 6)] = 20
#view updated array
print(my_array)
[20 20 20 7 8 8 20 20]
1593629580
Have you wanted to learn Regular Expressions in Python, but don’t know where to start? Have you stumbled into the dreaded pink SettingWithCopyWarning in Pandas? This week on the show, we have David Amos from the Real Python team to discuss a recent two-part series on Regex in Python. We also talk about another recent article on the site about views vs copies in Pandas. David also brings a few other articles and projects from the wider Python community for us to discuss.
#python #pandas #views #copies