Skip to content

Instantly share code, notes, and snippets.

View xinthink's full-sized avatar

Yingxin Wu xinthink

View GitHub Profile
@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 / 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 / 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 }}
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(
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);
}
class LoginScreen extends StatefulWidget {
@override
State<StatefulWidget> createState() => _LoginScreenState();
}
class _LoginScreenState extends State<LoginScreen> {
final _auth = FirebaseAuth.instance;
final _googleSignIn = GoogleSignIn();
String _errorMessage;
class Note {
final String id;
String title;
String content;
Color color;
NoteState state;
final DateTime createdAt;
DateTime modifiedAt;
/// Instantiates a [Note].
/// Home screen, displays [Note] in a Grid or List.
class HomeScreen extends StatefulWidget {
@override
State<StatefulWidget> createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
bool _gridView = true; // `true` to show a Grid, otherwise a List.
@override
class NotesGrid extends StatelessWidget {
final List<Note> notes;
final void Function(Note) onTap;
const NotesGrid({Key key, this.notes, this.onTap}) : super(key: key);
/// A static factory method can be used as a function reference
static NotesGrid create({Key key, this.notes, this.onTap}) =>
NotesGrid(key: key, notes: notes, onTap: onTap);
// The editor of a [Note], also shows every detail about a single note.
class NoteEditor extends StatefulWidget {
/// Create a [NoteEditor],
/// provides an existed [note] in edit mode, or `null` to create a new one.
const NoteEditor({Key key, this.note}) : super(key: key);
final Note note;
@override
State<StatefulWidget> createState() => _NoteEditorState(note);