Skip to content

Instantly share code, notes, and snippets.

View xinthink's full-sized avatar

Yingxin Wu xinthink

View GitHub Profile
class LoginScreen extends StatefulWidget {
@override
State<StatefulWidget> createState() => _LoginScreenState();
}
class _LoginScreenState extends State<LoginScreen> {
final _auth = FirebaseAuth.instance;
final _googleSignIn = GoogleSignIn();
String _errorMessage;
class CurrentUser {
final bool isInitialValue;
final FirebaseUser data;
const CurrentUser._(this.data, this.isInitialValue);
factory CurrentUser.create(FirebaseUser data) => CurrentUser._(data, false);
/// The inital empty instance.
static const initial = CurrentUser._(null, true);
}
void main() => runApp(NotesApp());
/// Root widget of the application.
class NotesApp extends StatelessWidget {
@override
Widget build(BuildContext context) => StreamProvider.value(
initialData: CurrentUser.initial,
value: FirebaseAuth.instance.onAuthStateChanged.map((user) => CurrentUser.create(user)),
child: Consumer<CurrentUser>(
builder: (context, user, _) => MaterialApp(
@xinthink
xinthink / check.yml
Last active November 7, 2019 05:33
medium-custom-github-actions check.yml
- name: notification
# uses: ./ # use relative path if this's the same repo of your action
uses: <user>/<repo>@v1
with:
botToken: <TelegramBotToken>
chatId: <TelegramChatId>
jobStatus: ${{ job.status }}
@xinthink
xinthink / package.json
Last active November 7, 2019 03:52
medium-custom-github-actions package.json
{
"scripts": {
"build": "tsc",
"clean": "rm -rf lib package-lock.json",
"rebuild": "yarn clean && yarn build",
"release": "yarn clean && yarn && yarn build && yarn npm-lock && mv -f package-lock.json npm.lock && rm -rf node_modules && yarn --prod && mv npm.lock package-lock.json",
"dev": "yarn clean && yarn",
"npm-lock": "synp -f -s yarn.lock"
}
}
@xinthink
xinthink / action.yml
Last active November 7, 2019 03:03
medium-custom-github-actions action.yml
name: 'Telegram Action'
description: 'Telegram notification for workflow set up with GitHub Actions'
author: <name>
inputs:
botToken:
description: 'The Telegram Bot token'
required: true
chatId:
description: 'The target to which the message will be sent, can be a Telegram Channel or Group'
required: true
@xinthink
xinthink / main.ts
Last active November 6, 2019 13:47
medium-custom-github-actions main.ts
import * as core from '@actions/core';
import { context } from '@actions/github';
import * as request from 'request-promise-native';
(async function run() {
try {
const botToken = core.getInput('botToken');
const chatId = core.getInput('chatId');
const jobStatus = core.getInput('jobStatus');
const skipSuccess = (core.getInput('skipSuccess') || 'true') === 'true';
@xinthink
xinthink / phases.csv
Last active November 7, 2019 04:54
medium-custom-github-actions
Branch/Tag Desc Development Distribution
master where we commit changes
releases/v{version} release candidates e.g. releases/v1.0
v{version} tags referred from workflows e.g. v1.0
@xinthink
xinthink / build.gradle
Created September 5, 2018 10:16 — forked from gpeal/build.gradle
Airbnb Gradle Flavors
...
apply from: './flavors.gradle'
...
android {
buildTypes {
productFlavors {
project.flavors.each { flavor, config ->
"$flavor" {
dimension 'scope'
if (flavor != 'full') {
@xinthink
xinthink / deps-ext.kt
Created November 15, 2017 01:42
Hook dependencies extension to ExtraProperties
val ExtraPropertiesExtension.deps: DependencyGroup
get() =
if (has("deps")) this["deps"] as DependencyGroup
else DependencyGroup().apply {
this@deps["deps"] = this
}