Hunter  Krajcik

Hunter Krajcik

1661172600

Action Handler: Simple Way to Decouple Actions From View

Action Handler

Simple way to decouple actions from View.

Actions

An action is everything that can interact with the user, but it's not a state.

Example 1: Navigate to another Page after some backend operation. The backend result should not be placed inside the button onPressed (because it's not its responsibility to deal with it), so it's safe to assume that this is an action.

Example 2: Show a non blocking error (dialog) after some operation. If it's necessary to show a dialog after some non blocking error, this logic should not me placed inside the button onPressed method, so this is probably an action too.

How to use it

There're 2 (two) available widgets: ActionHandler and ValueListenableActionHandler.

The first one uses Streams, the second one uses ValueNotifier. Once your Widget is completed, you MUST dispose the Stream/ValueNotifier.

ActionHandler<int>(
    actionInput: _controller.onStreamEvent,
    actionResult: (result) {
      print('Stream: $result \n');
    },
    child: Scaffold(
       appBar: AppBar(
         title: Text('Action Handler Demo'),
       ),
       body: Center(
         child: Text(
           'Push the button',
         ),
       ),
       floatingActionButton: FloatingActionButton(
         onPressed: _controller.increaseQuantity,
         tooltip: 'Increment',
         child: Icon(Icons.add),
       ),
     ),
   ),
  );

Use this package as a library

Depend on it

Run this command:

With Flutter:

 $ flutter pub add action_handler

This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):

dependencies:
  action_handler: ^1.0.1+2

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

Import it

Now in your Dart code, you can use:

import 'package:action_handler/action_handler.dart';

example/lib/main.dart

import 'package:action_handler/action_handler.dart';
import 'package:action_handler/value_listenable_action_handler.dart';
import 'package:example/main_controller.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) => MaterialApp(
        title: 'Flutter Demo',
        theme: ThemeData(
          primarySwatch: Colors.blue,
        ),
        home: MyHomePage(
          controller: MainController(),
        ),
      );
}

class MyHomePage extends StatefulWidget {
  MyHomePage({
    required this.controller,
    Key? key,
  }) : super(key: key);

  final MainController controller;

  @override
  State<StatefulWidget> createState() => _MyHomePageState();

}

class _MyHomePageState extends State<MyHomePage> {
  MainController get _controller => widget.controller;

  @override
  Widget build(BuildContext context) => ActionHandler<int>(
    actionInput: _controller.onStreamEvent,
    actionResult: (result) {
      print('Stream: $result \n');
    },
    child: ValueListenableActionHandler(
      actionInput: _controller.onNotifierEvent,
      actionResult: (result) {
        print('ValueNotifier: $result \n');
      },
      child: Scaffold(
        appBar: AppBar(
          title: Text('Action Handler Demo'),
        ),
        body: Center(
          child: Text(
            'Push the button',
          ),
        ),
        floatingActionButton: FloatingActionButton(
          onPressed: _controller.increaseQuantity,
          tooltip: 'Increment',
          child: Icon(Icons.add),
        ),
      ),
    ),
  );

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }
}

Download Details:

Author: mobyleOfficial
Source Code: https://github.com/mobyleOfficial/action_handler 
License: MIT license

#flutter #dart #action 

What is GEEK

Buddha Community

Action Handler: Simple Way to Decouple Actions From View
Hunter  Krajcik

Hunter Krajcik

1661172600

Action Handler: Simple Way to Decouple Actions From View

Action Handler

Simple way to decouple actions from View.

Actions

An action is everything that can interact with the user, but it's not a state.

Example 1: Navigate to another Page after some backend operation. The backend result should not be placed inside the button onPressed (because it's not its responsibility to deal with it), so it's safe to assume that this is an action.

Example 2: Show a non blocking error (dialog) after some operation. If it's necessary to show a dialog after some non blocking error, this logic should not me placed inside the button onPressed method, so this is probably an action too.

How to use it

There're 2 (two) available widgets: ActionHandler and ValueListenableActionHandler.

The first one uses Streams, the second one uses ValueNotifier. Once your Widget is completed, you MUST dispose the Stream/ValueNotifier.

ActionHandler<int>(
    actionInput: _controller.onStreamEvent,
    actionResult: (result) {
      print('Stream: $result \n');
    },
    child: Scaffold(
       appBar: AppBar(
         title: Text('Action Handler Demo'),
       ),
       body: Center(
         child: Text(
           'Push the button',
         ),
       ),
       floatingActionButton: FloatingActionButton(
         onPressed: _controller.increaseQuantity,
         tooltip: 'Increment',
         child: Icon(Icons.add),
       ),
     ),
   ),
  );

Use this package as a library

Depend on it

Run this command:

With Flutter:

 $ flutter pub add action_handler

This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):

dependencies:
  action_handler: ^1.0.1+2

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

Import it

Now in your Dart code, you can use:

import 'package:action_handler/action_handler.dart';

example/lib/main.dart

import 'package:action_handler/action_handler.dart';
import 'package:action_handler/value_listenable_action_handler.dart';
import 'package:example/main_controller.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) => MaterialApp(
        title: 'Flutter Demo',
        theme: ThemeData(
          primarySwatch: Colors.blue,
        ),
        home: MyHomePage(
          controller: MainController(),
        ),
      );
}

class MyHomePage extends StatefulWidget {
  MyHomePage({
    required this.controller,
    Key? key,
  }) : super(key: key);

  final MainController controller;

  @override
  State<StatefulWidget> createState() => _MyHomePageState();

}

class _MyHomePageState extends State<MyHomePage> {
  MainController get _controller => widget.controller;

  @override
  Widget build(BuildContext context) => ActionHandler<int>(
    actionInput: _controller.onStreamEvent,
    actionResult: (result) {
      print('Stream: $result \n');
    },
    child: ValueListenableActionHandler(
      actionInput: _controller.onNotifierEvent,
      actionResult: (result) {
        print('ValueNotifier: $result \n');
      },
      child: Scaffold(
        appBar: AppBar(
          title: Text('Action Handler Demo'),
        ),
        body: Center(
          child: Text(
            'Push the button',
          ),
        ),
        floatingActionButton: FloatingActionButton(
          onPressed: _controller.increaseQuantity,
          tooltip: 'Increment',
          child: Icon(Icons.add),
        ),
      ),
    ),
  );

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }
}

Download Details:

Author: mobyleOfficial
Source Code: https://github.com/mobyleOfficial/action_handler 
License: MIT license

#flutter #dart #action 

Monotone: An Unsplash Application for IOS

Monotone

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. (ヽ(✿゚▽゚)ノ)

Overview

screen-record-1.gif screen-record-2.gif



 

Development Progress

Features

  •  Write Interfaces Programmatically
  •  Dark Mode Support
  •  Animation Effects
  •  Localization
  •  Powered by Unsplash API
  •  More...

Tasks

Currently supported tasks:

PositionModulePageStyle & LayoutPowered by DataAnimation EffectsLocalization
MainLoginSign Up & Sign In
PhotoList (Search & Topic)
View
Camera Settings
Collect (Add & Remove)
Share to SNS⬜️
Save to Album
Side MenuProfileDetails
MenuMy Photos
Hiring⬜️
Licenses
Help⬜️
Made with Unsplash⬜️
Tab BarStoreHome⬜️
Details⬜️
WallpaperList (Adapt Screen Size)⬜️
CollectionList
ExploreList (Photo & Collection)⬜️



 

Getting Started

This application uses Cocoapods to manage dependencies. Please refer to Cocoapods Offical Website to install & configure(If you already installed Cocoapods, skip this).

Prerequisites

Monotone is trigged by Unsplash API . The very first thing must be done is applying a pair of OAuth key to run it.

  1. Visit Unsplash, sign up then sign in.(If you already have an account, skip this).
  2. Visit Unsplash Application Registration Platform agree with terms and create a new application, the application name and description can be anything.
  3. After the application was created,it will redirect to the application details page automatically (Also can be found from https://unsplash.com/oauth/applications). At Redirect URI & Permissions - Redirect URI section, input monotone://unsplash, make sure all authentication options are checked, just like the image shown below.

  1. After the work is finished, check ”Access Key“ and ”Secret Key“ on this page, they will be used soon.

Installation

  1. Execute the following commands in the terminal:
# Clone to a local folder
git clone https://github.com/Neko3000/Monotone.git

# Direct to Project folder
cd Monotone

# Install Pods
pod install
  1. Under Monotone folder, duplicate config_debug.json file,and rename it to config.json(This file is ignored by .gitignore);
  2. Open 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 );
  3. Done,command + R。

     

Dependencies

ProjectDescription
RxSwiftFramework for Reactive Async Programming.
ActionBased on RxSwift,encapsulate actions for calling。
DataSourcesBased on RxSwift,extend logic interaction of tableview and collectionview。
AlamofireHTTP network library.
SwiftyJSONHandle JSON format data effectively.
ObjectMapperMap data between models and JSON.
KingfisherNetwork image cache libray with many functions.
SnapKitMake constraints effectively.
......

For more information,please check Podfile

Project Structure

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.



 

About Unsplash

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)



 

Contributing

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.

How to Participate in

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:

  1. Fork this repo;
  2. Create your new Branch (git checkout -b feature/AmazingFeature);
  3. Add Commit (git commit -m 'Add some AmazingFeature');
  4. Push to remote Branch (git push origin feature/AmazingFeature);
  5. Open a 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

#swift 

Harsha  Shirali

Harsha Shirali

1669174554

Replace Elements in Python NumPy Array with Example

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.

Example 1 : Replace Elements Equal to Some Value

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]

Example 2: Replace Elements Based on One Condition

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]

Example 3: Replace Elements Based on Multiple Conditions

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]

#python 
 

Derek  Champlin

Derek Champlin

1597035960

GitHub Action Hero: Swechhya Bista

GitHub Actions gives you the power to automate your workflow. Connect with the tools you know and love. Have more freedom to innovate and be creative. Deploy to any cloud, build containers, automate messages, and lots more. It’s time to take control.

There’s lots of amazing Actions being built every day. We spoke to some of the coolest developers building the latest workflows and automations. Last week, we shared Samson’s story. This week we have Swechhya Bista. She also participated in our recent GitHub Actions Hackathon. Read her story for inspiration, lessons, and why developers choose to build.

#community #marketplace #open source #actions #github actions #r-action #swechhya bista

Ian  Robinson

Ian Robinson

1624422240

Actionable Insights Steer Industries Towards Better Business Decisions

In the current digital world, there is no industry that won’t benefit from actionable insights. With time, every industry will adapt to it. For example, in financial technology, a problem that requires actionable insights is credit risk assessment. A well-structured fintech algorithm can easily use machine learning to suggest to employees whether they can approve and reject a loan application. That advice is actionable insight.

The algorithm assesses the applicant’s probability of load success by training on heaps of historical data and market conditions. The result of the algorithm is the insightful judgment of the applicant’s acceptable or unacceptable risk. Action, in this case, is the human loan agent’s decision to grant the loan or deny it. The majority of businesses in today’s day and age depend on such insights. They require actionable insights incorporated in the workflows to drive better business outcomes without people having to leave their primary tasks to sieve through data for answers.

#big data #data analytics #action #decision to #actionable insights #actionable insights steer industries towards better business decisions