package org.mercury_im.messenger.android.ui.account.detail;

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import org.mercury_im.messenger.R;
import org.mercury_im.messenger.android.ui.MercuryActivity;
import org.mercury_im.messenger.android.util.ArgumentUtils;

import java.util.UUID;

import butterknife.ButterKnife;
import lombok.Value;

public class AccountDetailsActivity extends AppCompatActivity implements MercuryActivity {

    public static final String EXTRA_ACCOUNT_ID = "ACCOUNT_ID";

    private UUID accountId;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //MercuryImApplication.getApplication().getAppComponent().inject(this);

        Arguments arguments = getArguments(savedInstanceState);
        accountId = arguments.getAccountId();

        bindUiComponents();
    }

    private void bindUiComponents() {
        setContentView(R.layout.activity_fragment_container);
        ButterKnife.bind(this);

        getSupportFragmentManager().beginTransaction()
                .replace(R.id.fragment, new AccountDetailsFragment(accountId), "account_details")
                .commit();
    }

    private Arguments getArguments(Bundle bundle) {
        bundle = requiredExtras(bundle, getIntent());
        UUID accountId = ArgumentUtils.requireUUID(bundle, EXTRA_ACCOUNT_ID);
        return new Arguments(accountId);
    }

    @Value
    private class Arguments {
        UUID accountId;
    }
}
