thefaithapp_giving 0.1.0 copy "thefaithapp_giving: ^0.1.0" to clipboard
thefaithapp_giving: ^0.1.0 copied to clipboard

Authenticated, provider-extensible giving views for TheFaithApp Flutter applications.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:thefaithapp_auth/thefaithapp_auth.dart';
import 'package:thefaithapp_giving/thefaithapp_giving.dart';

void main() => runApp(const GivingExampleApp());

class GivingExampleApp extends StatefulWidget {
  const GivingExampleApp({super.key});

  @override
  State<GivingExampleApp> createState() => _GivingExampleAppState();
}

class _GivingExampleAppState extends State<GivingExampleApp> {
  static const _campaignId = int.fromEnvironment('THEFAITHAPP_CAMPAIGN_ID');
  final _auth = TheFaithAppAuth(
    apiKey: const String.fromEnvironment(
      'THEFAITHAPP_API_KEY',
      defaultValue: 'your-client-key',
    ),
  );
  late final TheFaithAppGiving _giving = TheFaithAppGiving(auth: _auth);
  bool _signedIn = false;

  @override
  void dispose() {
    _giving.dispose();
    _auth.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) => MaterialApp(
    title: 'TheFaithApp Giving',
    theme: ThemeData(colorSchemeSeed: Colors.indigo),
    home: Scaffold(
      appBar: AppBar(title: const Text('Giving example')),
      body: _signedIn
          ? _givingViews()
          : Center(
              child: FilledButton(
                onPressed: _signIn,
                child: const Text('Sign in to give'),
              ),
            ),
    ),
  );

  Widget _givingViews() {
    if (_campaignId < 1) return GivingView.general(giving: _giving);
    return DefaultTabController(
      length: 2,
      child: Column(
        children: [
          const TabBar(
            tabs: [
              Tab(text: 'General'),
              Tab(text: 'Campaign'),
            ],
          ),
          Expanded(
            child: TabBarView(
              children: [
                GivingView.general(giving: _giving),
                GivingView.campaign(giving: _giving, campaignId: _campaignId),
              ],
            ),
          ),
        ],
      ),
    );
  }

  Future<void> _signIn() async {
    await _auth.signIn();
    if (mounted) setState(() => _signedIn = true);
  }
}
0
likes
150
points
--
downloads

Documentation

API reference

Publisher

unverified uploader

Authenticated, provider-extensible giving views for TheFaithApp Flutter applications.

Homepage
Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter, flutter_stripe, http, thefaithapp_auth, webview_flutter

More

Packages that depend on thefaithapp_giving